Shipping Extension Zones
-
Hi all, I need with creating a shipping extension. I need to limit the number of states, zones, regions or provinces we service under a specific country. At the moment I can only limit according to the country. I have this in my php file:
public function __construct() { $this->id = 'tiki_lite'; $this->method_title = __('Tiki Local Delivery'); $this->method_description = __('Custom local delivery method for Tiki Lite'); $this->availability = 'including'; $this->countries = array( 'ZA', 'ES', 'US', 'GB' ); $this->init(); $this->enabled = isset($this->settings['enabled']) ? $this->settings['enabled'] : 'yes'; $this->title = isset($this->settings['title']) ? $this->settings['title'] : __('Tiki Local Delivery', 'tiki_lite'); }
which works fine for limiting the country. But I tried to use this:
public function __construct() { $this->id = 'tiki_lite'; $this->method_title = __('Tiki Local Delivery'); $this->method_description = __('Custom local delivery method for Tiki Lite'); // Contreis availability $this->availability = 'including'; $this->countries = array( 'ZA', 'ES', 'US', 'GB' ); $this->states['ZA'] = array( 'GP' => __( 'Gauteng', 'Tiki Lite' ) ); $this->init(); $this->enabled = isset($this->settings['enabled']) ? $this->settings['enabled'] : 'yes'; $this->title = isset($this->settings['title']) ? $this->settings['title'] : __('Tiki Local Delivery', 'tiki_lite'); }
and it made no difference. I then tried the following code:
add_filter( 'woocommerce_states', 'custom_woocommerce_states' ); function custom_woocommerce_states( $states ) { $states['ZA'] = array( 'GP' => __( 'Gauteng', 'tiki_lite' ) ); return $states; }
which just limited the allowed shipping states for the whole of WooCommerce. I want users to be able to choose states, then for the extension to disable the extension if the chosen state is not a state we serve.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Shipping Extension Zones’ is closed to new replies.