WooCommerce removing shipping from 2 product categories php help
-
HI, I am using WooCommerce for our cart and have several product categories that ship in different ways. Currently I have one category that is for pick up in-store only and lists the store hours with an area to sign up for when you want to pick up your item.
I already have the php in place and working for a single product category and need to add a second category to do the same thing.
Here is the php, it works by removing the shipping options available for other product categories and adding a list of store hours and a in-store pick up window to select the day and time you want to pick up. The category party-boards is up and running, but I need to add the category picnic-boxes to this.
marche496.com, if you go to Shop and add a Party and all occasion board to the cart and then go to check out, you can see how it works toward the bottom of the page.
Anyone know how to add a second category to this php? TIA
/*-----------------------------------------------------------------------------------*/ /* WooCommerce Opening Hours & Chosen Times /*-----------------------------------------------------------------------------------*/ function my_openinghours_label_timechosen($m) { return "Your Pickup Time"; } add_filter('openinghours_label_timechosen', 'my_openinghours_label_timechosen'); function marche_choosepickuptime_label($m) { return "Party Boards are for in-store pickup only. Our Store Hours are<br> <i class='icon-cancel-circled'></i> Closed Monday<br> <i class='icon-clock'></i> 11am – 7pm Tuesday, Wednesday, Friday<br> <i class='icon-clock'></i> 11am – 8pm Thursday<br> <i class='icon-clock'></i> 11am – 6pm Saturday<br> <i class='icon-clock'></i> 12pm – 5pm Sunday<br> <h3 id='party-boards-select-time'>Please select your preferred pickup time.</h3>"; } add_filter('openinghours_frontendtext_choicelabel', 'marche_choosepickuptime_label'); /*-----------------------------------------------------------------------------------*/ /* WooCommerce Opening Hours & Chosen Times only if Party Boards /*-----------------------------------------------------------------------------------*/ function action_woocommerce_after_checkout_billing_form( $checkout ) { global $woocommerce; $lundi_in_cart = false; foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) { $_product = $values['data']; $terms = get_the_terms( $_product->id, 'product_cat' ); foreach ($terms as $term) { $_categoryid = $term->term_id; } if (( $_categoryid === 10 )) { $product_in_cart = true; } } if (! $product_in_cart == true ) { wc_enqueue_js( " $( 'p.openinghours-initial-display-block' ).hide(); $( '#openinghours_time' ).hide(); $( '#party-boards-select-time' ).hide(); " ); } }; add_action( 'woocommerce_after_checkout_billing_form', 'action_woocommerce_after_checkout_billing_form', 10, 1 );
- The topic ‘WooCommerce removing shipping from 2 product categories php help’ is closed to new replies.