Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do_action( 'woocommerce_shipping_method_chosen', 'check_if_dhl', 10, 1 );
- function check_if_dhl( $chosen_method ) {
- global $woocommerce;
- $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
- $chosen_shipping_no_ajax = get_shipping_name_by_id($chosen_methods[0]);
- if (strpos($chosen_shipping_no_ajax, 'DHL') !== false) {
- // 184 is the product ID of the box package
- WC()->cart->add_to_cart( 184 );
- } else {
- // A function I wrote to simplify removing of a product from cart.
- remove_product_from_cart( 184 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement