Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add districts with zipcodes, so the REST API can be filtered using a … #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

richardkorthuis
Copy link
Member

…zipcode.

Copy link
Contributor

@mvdhoek1 mvdhoek1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vergeet niet om de version bumps toe te voegen aan Foundation/Plugin.php, openpub-base.php en aan de CHANGELOG.md

@@ -107,4 +107,25 @@ public static function addTypeParameter(string $type): array
]
];
}

public static function addZipcodeParameter(string $zipcode): array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eindigen met een happy path heeft mijn voorkeur:

	public static function addZipcodeParameter(string $zipcode): array
	{
		global $wpdb;
		$sql = "SELECT term_id FROM {$wpdb->termmeta} WHERE meta_key = '_owc_openpub_zipcode' AND meta_value = %s";
		$results = $wpdb->get_col($wpdb->prepare($sql, (int)$zipcode));

		if (! $results) {
			return [];
		}

		return [
			'tax_query' => [
				[
					'taxonomy' => 'openpub-district',
					'terms' => $results,
					'field' => 'term_id',
					'operator' => 'IN'
				]
			]
		];
	}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dit heb ik aangepast.

# Conflicts:
#	languages/openpub-base-nl_NL.mo
#	languages/openpub-base-nl_NL.po
#	languages/openpub-base.pot
#	src/Base/RestAPI/Controllers/ItemController.php
@richardkorthuis
Copy link
Member Author

Vergeet niet om de version bumps toe te voegen aan Foundation/Plugin.php, openpub-base.php en aan de CHANGELOG.md

Leek me logisch om dat pas te doen als de PR was gemerged, maar bij deze gedaan

@mvdhoek1 mvdhoek1 force-pushed the feature/add-districts branch from 23a0d73 to c20dfe4 Compare April 29, 2024 14:08
@mvdhoek1 mvdhoek1 requested a review from robertbossaert April 29, 2024 14:09
@mvdhoek1
Copy link
Contributor

@robertbossaert kun jij nog even checken, anders kan er niet gemerged worden.


#: config/metaboxes.php:156
msgid "A zipcode that is part of this district. (Only numbers, no letters)"
msgstr "Een postcode die bij deze wijk hoort. (Alleen cijfer, geen letters)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kun je hier nog cijfers van maken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants