Additional Add to cart button
-
Hello!
I am trying to ad a AD TO CART BUTTON After original add to cart button. This new button would add three items to the cart.
Everything works fine except I would like to filter it, that it will be shown only for product with id 282.The following code adds button to all products.
Can you please assist me what am I doing wrong. Thanks!add_action( 'woocommerce_after_add_to_cart_button', 'additional_simple_add_to_cart', 3 ); function additional_simple_add_to_cart() { global $product; if( ! $product->is_type('simple') && is_product_category( '282' ) ) return; $href = '?add-to-cart=' . esc_attr( $product->get_id() ) . '&quantity=3'; $class = 'ingle_add_to_cart_button-12 button alt'; $style = 'display: inline-block; margin-top: 12px;'; $button_text = __( "Add to cart 3x product", "woocommerce" ); // Output echo '<br><a rel="no-follow" href="'.$href.'" class="'.$class.'" style="'.$style.'">'.$button_text.'</a>'; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Additional Add to cart button’ is closed to new replies.