Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, thank you for your help.

    I´m starting with my first web page and I’m building it in local host, so I don’t have yet any available URL at internet. I will look for a free hosting as soon as possible to send you the shop archive page link.

    In the meanwhile, I will follow your suggestions.

    Thanks again.

    Hi,

    I need to display different units next to the quantity button depending on the type of my products. So, I included an individual label for each product as you suggest:

    #product-211 .quantity:after {content:”Unit01″; margin-left:10px}
    #product-212 .quantity:after {content:”Unit02″; margin-left:10px}
    etc…

    However, I also need to include the quantity button with its corresponding label within my shop archive pages and I found the following code to do it (https://docs.woocommerce.com/document/override-loop-template-and-show-quantities-next-to-add-to-cart-buttons/).

    <?php
    /**
    * Code should be placed in your theme functions.php file.
    */
    add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘quantity_inputs_for_woocommerce_loop_add_to_cart_link’, 10, 2 );
    function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
    if ( $product && $product->is_type( ‘simple’ ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
    $html = ‘<form action=”‘ . esc_url( $product->add_to_cart_url() ) . ‘” class=”cart” method=”post” enctype=”multipart/form-data”>’;
    $html .= woocommerce_quantity_input( array(), $product, false );
    $html .= ‘<button type=”submit” class=”button alt”>’ . esc_html( $product->add_to_cart_text() ) . ‘</button>’;
    $html .= ‘</form>’;
    }
    return $html;
    }

    With this code, the quantity button appears in the shop archive pages but the unit label is missing. Could anybody help me with this?

    Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)