[Resolved] WooCommerce plus minus buttons on categories/loop

Home Forums Support [Resolved] WooCommerce plus minus buttons on categories/loop

Home Forums Support WooCommerce plus minus buttons on categories/loop

  • This topic has 1 reply, 1 voice, and was last updated 1 month ago by Carlos.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2282882
    Carlos

    Hi, I use GeneratePress Pro and I have enables plus minus buttons that show nice on single products, but in the loop I see the Add to cart button, and I’d like to change to the plus/minus and quantity with a cart button. There is an option or code for this? I see a class do-quantity-buttons on the li element inside the loop, but not quantity buttons.

    Kindly regards, Carlos Longarela.

    #2282925
    Carlos

    Oh, I fixed it showing the woocommerce_quantity_input with this code:

    /**
     * Override loop template and show quantities next to add to cart buttons.
     *
     * @param string $html    HTML of the add to cart button.
     * @param object $product Product object.
     *
     * @return string
     */
    function cl_woo_quantity_inputs_loop( $html, $product ) {
    	if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() ) {
    		$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;
    }
    add_filter( 'woocommerce_loop_add_to_cart_link', 'cl_woo_quantity_inputs_loop', 10, 2 );
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.