Guest User

Untitled

a guest
May 26th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // Prevent Redirect after cart error
  2. add_filter( 'woocommerce_cart_redirect_after_error', '__return_false');
  3. add_action( 'woocommerce_add_to_cart_validation', 'restrict_only_one_item_in_cart' );
  4.  
  5. function restrict_only_one_item_in_cart($cart_item_data) {
  6.  
  7. global $woocommerce;
  8. $item_count = $woocommerce->cart->cart_contents_count;
  9.  
  10. if($item_count >= 20){
  11. return false;
  12. }
  13. return $cart_item_data;
  14. }
  15.  
  16. if((is_page('strongshop') || is_page('strongshopmobile')) && $item_count >= 20){
  17. return false;
Add Comment
Please, Sign In to add comment