[Support request] Add to Cart button (oos)

Home Forums Support [Support request] Add to Cart button (oos)

Home Forums Support Add to Cart button (oos)

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1652669
    Ash

    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.

    #1652934
    David
    Staff
    Customer Support

    Hi 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.

    #1653973
    Ash

    Hi 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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.