wpgenie

pick number table only on lottery single page where _lottery

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