I'm using a plugin that connect to a "Shipping Services Provider" via API and during the checkout process it will provide one value (the cheapest courier company) based on the customer's shipping postcode. But the value kept changing based on the courier company. Below are some samples of the returned value:
- SSP-ABC
- SSP-DEF
- SSP-GHI
Is it possible to set WooCommerce shipping method programatically using wildcard (something like this: SSP-*) during the "Checkout" process?
Below are the codes that I'm using to set the shipping methods but it won't support wildcard as far as I know:
WC()->session->set('chosen_shipping_methods', array('xxxxxx') );
Is there any other method that I can use to set the Shipping Methods using wildcard (SSP-*)? Any suggestion is highly appreciated.
ADDED FOR CLARIFICATION:
Below are two samples returned by the API as the Shipping option on the "Checkout" page based on two different postcodes:
<input name="shipping_method[0]" data-index="0" id="shipping_method_0_ssp-abc" value="SSP-ABC" class="shipping_method" type="radio">
or
<input name="shipping_method[0]" data-index="0" id="shipping_method_0_ssp-def" value="SSP-DEF" class="shipping_method" checked="checked" type="radio">
The code below was not able to checked the radio button if the value changes to "SSP-DEF":
WC()->session->set('chosen_shipping_methods', array('SSP-ABC'));