Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WooCommerce - Show custom message in cart totals
- add_action( 'woocommerce_cart_totals_after_shipping', 'custom_cutting_message', 10 );
- function custom_cutting_message() {
- $cart = WC()->cart;
- $subtotal = $cart->get_subtotal();
- if( $subtotal > 450 ) {
- return;
- }
- // loop over $cart items
- $includes_delivery_roll_cutting_class = false;
- foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
- $product = $cart_item['data'];
- $shipping_class = $cart_item['data']->get_shipping_class(); // product shipping class slug
- if( 'delivery-roll-cutting' == $shipping_class ) {
- $includes_delivery_roll_cutting_class = true;
- break;
- }
- }
- if( $includes_delivery_roll_cutting_class ) {
- print '<tr><th colspan="2" class="shipping_message">This includes cutting the roll.<br>Spend over £450 for free roll cutting and delivery.</th></tr>'.PHP_EOL;
- } else {
- print '<tr><th colspan="2" class="shipping_message">Spend over £450 for free delivery.</th></tr>'.PHP_EOL;
- }
- } // end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement