-
Notifications
You must be signed in to change notification settings - Fork 2
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
Agent search by postal code + filters #25
base: main
Are you sure you want to change the base?
Conversation
@Saggre Thanks for the PR - the issue regarding Klarna is clearly worth addressing. I suggest that instead of implementing multiple filters, then a single filter is added like so: $agentSearchAddress = apply_filters('smart_send_agent_search_address', [
'country' => empty($_POST['s_country']) ? null : wc_clean($_POST['s_country']),
'postal_code' => empty($_POST['s_postcode']) ? null : wc_clean($_POST['s_postcode']),
'city' => empty($_POST['s_city']) ? null : wc_clean($_POST['s_city']),
'address' => empty($_POST['s_address']) ? null : wc_clean($_POST['s_address']),
]); let me know if this would cover the use-case you have in mind? |
@bilfeldt Yeah, this will work as well as long as city and street are allowed to be empty after the filter (and postal code search will be used as a fallback) if(empty($street) || strlen($street) < 5){
$ss_agents = $this->find_closest_agents_by_postal_code($carrier, $country, $postal_code);
}else{
$ss_agents = $this->find_closest_agents_by_address($carrier, $country, $postal_code, $city, $street);
} |
Implement a single filter 'smart_send_agent_search_address'
@Saggre I have made the proposed changes now. Do you agree this will solve the challenges you have had? |
@bilfeldt Yeah this will solve our problem. I just removed an extra comma |
Add the following filters for modifying agent search address:
smart_send_agent_search_country
smart_send_agent_search_postal_code
smart_send_agent_search_city
smart_send_agent_search_street
and allow searching for agents with just country and postcode when no street is provided.
My use case for this is that some payment gateways like Klarna (widely used in many countries that PostNord also operates in), only dynamically update shipping country and postcode at checkout and leave city and street address blank. This solution should work out of the box with Klarna and gives more flexibility to users.