php code for weight based shipping plug in
-
Hi there, I hope someone here can help. I posted this elsewhere, but it seems more appropriate to post it here.
I need to be able exclude a group of products from weight based shipping in favour of flat rate, but still keep weight based shipping as the main/default shipping system.
I’ve been using a reworked version of the ‘hide other shipping methods’ code, but so far it has only returned an error:
call_user_func_array() expects parameter 1 to be a valid callback, function ‘hide_standard_shipping_when_free_is_available’ not found or invalid function name in /home/poppyl5/public_html/wp-includes/plugin.php on line 173
Basically I exchanged ‘free shipping’ for ‘flat rate’ but it doesn’t to be quite that simple.
function hide_all_shipping_when_flat_rate_is_available( $available_methods ) { if( isset( $available_methods['flat_rate'] ) ) : // Get Flat Rate array into a new array $flatrate = array(); $flatrate = $available_methods['flat_rate']; // Empty the $available_methods array unset( $available_methods ); // Add Flat Rate back into $avaialble_methods $available_methods = array(); $available_methods[] = $flatrate; endif; return $available_methods; }
I’m just starting out with php, so if you have an answer, please make it easily understandable for a beginner. It would be great if you could give an explanation too, so I can go away, think it through and add another level of understanding to my programming.
Thankyou in advance ??
The site I’m working on is based around Woocommerce and Wootique.
If you need anything making clearer, just ask.
- The topic ‘php code for weight based shipping plug in’ is closed to new replies.