• I am trying to add quantity button on woocommerce product page, My add_to_cart.php is as follow :

    if ( ! defined( 'ABSPATH' ) ) {
        exit; // Exit if accessed directly
    }
    
    global $product;
    $alr = $product->id;
    
    echo apply_filters( 'woocommerce_loop_add_to_cart_link',
        sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" onClick="return checkalert('.$alr.');" class="btn btn-mini btn-info %s product_type_%s">%s</a>',
            esc_url( $product->add_to_cart_url() ),
            esc_attr( $product->id ),
            esc_attr( $product->get_sku() ),
            esc_attr( isset( $quantity ) ? $quantity : 1 ),
            $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
            esc_attr( $product->product_type ),
            esc_html( $product->add_to_cart_text() )
        ),
    $product );

    and the form to display is as follow :

    <form>
    <label for="" class="control-label-cus" style="color:#fff;line-height: 1.9; ">Quantity</label><?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); 
    
    ?>

    but when I am trying to display is displayed on product page when I change the quantity in this field and add to cart, it added to cart but on cart page,it shows the quantity as one again instead of the quantity that I selected on product page

    https://www.ads-software.com/plugins/woocommerce/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Unable to add quantity on product’ is closed to new replies.