I am currently using a WordPress so please help me how can I add drop-down for my vegetables quality based pricing on shop page not on product page I have that drop-down but it shows only in product page I want to show that on home page you can check my website :- www.nagpurveggies.com

1 Answer 1


I guess you are looking for this enter image description here Source : https://iconicwp.com/blog/show-variations-shop-page-woocommerce/

 * Replace add to cart button in the loop.
function iconic_change_loop_add_to_cart() {
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    add_action( 'woocommerce_after_shop_loop_item', 'iconic_template_loop_add_to_cart', 10 );

add_action( 'init', 'iconic_change_loop_add_to_cart', 10 );

 * Use single add to cart button for variable products.
function iconic_template_loop_add_to_cart() {
    global $product;

    if ( ! $product->is_type( 'variable' ) ) {

    remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
    add_action( 'woocommerce_single_variation', 'iconic_loop_variation_add_to_cart_button', 20 );


 * Customise variable add to cart button for loop.
 * Remove qty selector and simplify.
function iconic_loop_variation_add_to_cart_button() {
    global $product;

    <div class="woocommerce-variation-add-to-cart variations_button">
        <button type="submit" class="single_add_to_cart_button button"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
        <input type="hidden" name="add-to-cart" value="<?php echo absint( $product->get_id() ); ?>" />
        <input type="hidden" name="product_id" value="<?php echo absint( $product->get_id() ); ?>" />
        <input type="hidden" name="variation_id" class="variation_id" value="0" />
  • 1
    Worked for me! Ajax will work for the simple product option, but for variable products you will be redirected to the product page. You can use the woocommerce_add_to_cart_redirect filter to avoid that.
    – Marc
    Jan 29, 2020 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.