• Resolved tiendabs

    (@tiendabs)


    Hello. How can I change so that the add to cart button is not with quantity and is simply the add to cart button, but without css?
    Greetings

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Kris

    (@c0nst)

    Hi @tiendabs!

    I assume you want to hide quantity input in the FiboSearch Details panel. You can do that with this CSS:

    .dgwt-wcas-pd-addtc-form .quantity {
    	display: none !important;
    }

    If you want to hide this everywhere in your shop use this code:

    .quantity {
    	display: none !important;
    }

    Paste it into Appearance -> Customize -> Additional CSS. If you aren’t familiar with custom CSS, take a look at this video.

    Regards,
    Kris

    Thread Starter tiendabs

    (@tiendabs)

    Thanks for answering. My problem is another.
    Today I have a code

    ********************************

    add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘dcms_add_quantity_field’, 10, 2 );
    function dcms_add_quantity_field($html, $product) {
    if ( is_user_logged_in() ) {
    if($product&&
    $product->is_type(‘simple’)&&
    $product->is_purchasable()&&
    $product->is_in_stock()&&
    !$product->is_sold_individually()){

            $html='<form class="cart" action="'. esc_url($product->add_to_cart_url()).'" method="post" enctype="multipart/form-data">';
            $html.= woocommerce_quantity_input(array(),$product,false);
            $html.='<button type="submit" data-quantity="1" data-product_id="'.$product->get_id().'" class="primary is-small mb-0 button wp-element-button product_type_simple add_to_cart_button ajax_add_to_cart is-outline" style="border-radius: 10px;">'. esc_html($product->add_to_cart_text()).'</button>';
            $html.='</form>';
        }
        return $html;

    }
    }

    //Agreamos código javascript
    add_action( ‘init’, ‘dcms_quantity_change’ );
    function dcms_quantity_change() {
    wc_enqueue_js(‘
    (function( $ ) {
    $(“form.cart”).on(“change”, “input.qty”, function() {
    $(this.form).find(“[data-quantity]”).attr(“data-quantity”, this.value);
    });
    })( jQuery );
    ‘);
    }

    *****************************************

    that adds the possibility of adding by quantity to the products in the catalog. What this causes me is that the search engine shows 2 quantity fields, you can see it at torres3.open24.com.ar and only one works. By modifying the plugin I remove it, but when updating I lose it again.

    Plugin Support Kris

    (@c0nst)

    Hi, @tiendabs!

    With the below code you can do the same which is hide add to cart button everywhere on the shop where your conditions are not met (user logged in, simple, purchasable, in-stock, and individually-sold product):

    add_filter( 'woocommerce_loop_add_to_cart_link', function ( $html, $product ) {
    	if ( should_add_quantity_field( $product ) ) {
    	} else {
    	  $html = '';
    	}
    
    	return $html;
    }, 10, 2 );
    
    add_filter( 'dgwt/wcas/suggestion_details/product/html', function ( $html, $product_id ) {
    	$woo_product = wc_get_product( $product_id );
    
    	if ( ! should_add_quantity_field( $woo_product ) ) {
    	  $html = preg_replace( '#<div class="dgwt-wcas-pd-addtc js-dgwt-wcas-pd-addtc">(.+?)</form>#s', '<div>', $html );
    	}
    
    	return $html;
    }, 10, 2 );
    
    
    function should_add_quantity_field( $product ) {
    return is_user_logged_in() && 
           $product && 
           $product->is_type('simple') && 
           $product->is_purchasable() && 
           $product->is_in_stock() && 
           !$product->is_sold_individually();
    }

    You have two ways to add this code to your theme:

    1. Open the?functions.php?in your child theme and add the code at the end.
    2. ?or install the?Code Snippets?plugin and apply this code as a snippet.

    Regards,
    Kris

    Thread Starter tiendabs

    (@tiendabs)

    Muchas gracias

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