- This topic has 2 replies, 2 voices, and was last updated 3 years, 2 months ago by Ash.
-
AuthorPosts
-
February 10, 2021 at 1:14 am #1652669Ash
So we are having issues with a merchant center suspension, we hired a Google Platinum Product Expert. Fixed several issues, but google states the following;
A user must see the following, title, image, price, description, availability and add to cart button. No modification at any given time.
He saying the add to cart button must be shown even if a product is out of stock. Strange I know!
Is there a way to force the button to show? It just needs to be able to add to cart, Woocommerce will show a warning for out of stock products in the cart anyways and not allow a user to checkout.
I know I can use backorder with notify user but I don’t want oos products being ordered regardless.
February 10, 2021 at 5:57 am #1652934DavidStaffCustomer SupportHi there,
you would need to ask Woocommerce support on how to do that – i had a look around but couldn’t see any obvious methods for it aside of setting a product on back order.
February 11, 2021 at 12:44 am #1653973AshHi David,
Thanks, that’ what they suggested I do, But it allows a user to checkout, And due to the pandemic some products are taking months to arrive so this wouldnt work. This is the code that checks for in stock and adds cart form, quantity and button
defined( 'ABSPATH' ) || exit; global $product; if ( ! $product->is_purchasable() ) { return; } echo wc_get_stock_html( $product ); // WPCS: XSS ok. if ( $product->is_in_stock() ) : ?> <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?> <form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'> <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?> <?php do_action( 'woocommerce_before_add_to_cart_quantity' ); woocommerce_quantity_input( array( 'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. ) ); do_action( 'woocommerce_after_add_to_cart_quantity' ); ?> <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button> <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?> </form> <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?> <?php endif; ?>
Just need to chnage the first part to include out of stock.
-
AuthorPosts
- You must be logged in to reply to this topic.