wpgenie

ticket numbers full width - only for single product lottery

Jun 25th, 2020
2,478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. /* This code should go to your child theme's functions.php file. Displays pick number table only on single lottery page for lotteries that have manual ticket number picking enabled. */
  2.  
  3. add_action( 'template_redirect' , 'custom_remove_and_add_actions',99 );
  4. function custom_remove_and_add_actions(){
  5.     global $product;
  6.     if ( ! is_object( $product)) $product = wc_get_product( get_the_ID() );
  7.     if ( $product && $product->get_type() == 'lottery' && (get_post_meta( $product->get_id() , '_lottery_use_pick_numbers', true ) === 'yes') ) {
  8.         remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
  9.         add_action('woocommerce_after_single_product_summary', 'woocommerce_template_single_add_to_cart', 1);
  10.     }  
  11. }
Advertisement
Add Comment
Please, Sign In to add comment