Coupon rounding script in child theme causes WP to crash
-
When this script is added the site crashes, with or without backorder snippet.
<?php /** * Round off decimals for coupons **/ function filter_woocommerce_coupon_get_discount_amount( $discount, $discounting_amount, $cart_item, $single, $instance ) { $discount = round( $discount, 1 ); return $discount; } add_filter( 'woocommerce_coupon_get_discount_amount', 'filter_woocommerce_coupon_get_discount_amount', 10, 5 ); } /**-------------------------**/ /**Do not allow coupons to be applied to products in backorder in WooCommerce on your child site. *Snippet Type *Execute on Child Sites *Snippet **/ function filter_woocommerce_coupon_get_discount_amount( $discount, $price_to_discount , $cart_item, $single, $coupon ) { // On backorder if ( $cart_item['data']->is_on_backorder() ) { $discount = 0; } return $discount; } add_filter( 'woocommerce_coupon_get_discount_amount', 'filter_woocommerce_coupon_get_discount_amount', 10, 5 );
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Coupon rounding script in child theme causes WP to crash’ is closed to new replies.