• Resolved magedmoh94

    (@magedmoh94)


    Hi Moiseh,

    Its really a great work you keep doing man & we really appreciate that .. you always stand by our side to make your plugin compatible with every solution.

    We had an issue today with the dropdown menu option, it doesn’t happen when dropdown is disabled in your plugin and work with the +/- option, but with the dropdown option activated instead of the +/- the issue happens:

    Our setup that we use your plugin with activating the dropdown without the +/- option and max input value is 10.

    We use the snippet below to limit some products only by their slut to have a specific qualities where is the max is 10 too but we need the drop down to have 5,10 only in that case.

    add_filter( 'woocommerce_quantity_input_args', 'ts_woocommerce_quantity_selected_number', 10, 2 );
      
    function ts_woocommerce_quantity_selected_number( $args, $product ) {
     // global $product;
       if ( ! is_cart() ) {
     if ($product->get_slug()=="group-ticket"){
          $args['input_value'] = 5; // Start from this value (default = 1) 
          $args['max_value'] = 10; // Maximum quantity (default = -1)
          $args['min_value'] = 5; // Minimum quantity (default = 0)
          $args['step'] = 5; // Increment or decrement by this value (default = 1)
     }
       } else {
     if ($product->get_slug()=="group-ticket"){
          // Cart's 'min_value' is 0
          $args['max_value'] = 10; 
          $args['step'] = 5; 
          $args['min_value'] = 5;
     }
       }
      
       return $args; 
    }

    It works fine with the +/- option in your plugin if we disabled the dropdown menu, so how can we make it work too with the dropdown instead of the +/- and when this specific product so the dropdown will have the 5,10 quantities only.

    Thank you so much for the great work

    Stay Safe for you & your family

    Best Regards

    • This topic was modified 4 years, 1 month ago by magedmoh94.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author moiseh

    (@moiseh)

    Hello,
    Thanks for reporting the issue.
    Just fixed in new version.
    Regards

    Thread Starter magedmoh94

    (@magedmoh94)

    Hi Moiseh,

    Worked like a charm !!

    We really appreciate how fast & responsive and care to make the plugin work for all the situations .. thank you so much moiseh for making our life with woocommerce easier

    Stay safe for you & your family

    Best Regards

    Thread Starter magedmoh94

    (@magedmoh94)

    Hi Moiseh,

    We been trying to make the snippet above to achieve another scenario to make the dropdown quantities to be 0,3,4,5,6,7,8,9,10 .. we have achieved it but without the start of 0.

    as we need it to start with 0 then 3 then 4 then 5,etc .. to be 0,3,4,5,6,7,8,9,10.

    is that a compatibility issue or what ?

    Sorry for disturbance

    have a nice day

    Stay Safe & Best Regards

    • This reply was modified 4 years, 1 month ago by magedmoh94.
    Thread Starter magedmoh94

    (@magedmoh94)

    Hi Moiseh,

    The first scenario works great and we use it in a part of the website.

    But the 2nd scenario below doesn’t, so we opened the ticket again to be able to realize it.

    So lets keep the first code above working its great. but need the one below to work too

    We have found another code that we were trying to make it work with your plugin so can you make it compatible, sorry for that too but we are on production site and having this issue unfortunately.

    The code below found by help from this: https://aceplugins.com/making-the-quantity-field-a-dropdown-in-woocommerce/

    /**
     * Add additional quantity input field $args
     *
     * @param WC_Product $product
     */
    function ace_quantity_input_field_args( $args, $product ) {
    	if (  if ($product->get_slug()=="grocery ") ) {
    		$args['dropdown_steps'] = array( 0, 3, 4, 5, 6, 7, 8, 9 , 10);
    	}
    
    	return $args;
    }
    add_filter( 'woocommerce_quantity_input_args', 'ace_quantity_input_field_args', 10, 2 );

    I think what is not right that the $arg['dropdown_steps'] is the part we need to make it work with your plugin right ?

    Plugin Author moiseh

    (@moiseh)

    Hello Sir,

    I’ve just added the compatibility to work like in the example for this specific case.

    Code i used to ensure that works:

    function my_quantity_input_field_args( $args, $product ) {
    	$args['dropdown_steps'] = array( 0, 3, 4, 5, 6, 7, 8, 9 , 10);
    	return $args;
    }
    
    add_filter( 'woocommerce_quantity_input_args', 'my_quantity_input_field_args', 10, 2 );
    Thread Starter magedmoh94

    (@magedmoh94)

    @moiseh

    Hi Moiseh,

    Worked great and thank you for making our life easier to make it work in every situation but it has a little issue, when tested 2 solutions to fix it the first one below:

    function my_quantity_input_field_args( $args, $product ) {
    
    		$args['dropdown_steps'] = array( 0, 3, 4, 5, 6, 7, 8, 9 , 10);
      
        return $args; 
    }
    add_filter( 'woocommerce_quantity_input_args', 'my_quantity_input_field_args', 10, 2 );

    When we click add to product when the quantity is 0 on product page, the quantity field on cart is 0 too & the price is for 1 product .. while we need when we click on product page add to cart when the quantity field is 0 to reflect in the cart quantity field is 3 and the price of 3 products not just 1.

    So we tried another solution to fix this to make the dropdown defined quantities to reflect on the product page only not on cart.

    function my_quantity_input_field_args( $args, $product ) {
    
            // Not In cart
            if ( ! is_cart() ) {
    				$args['dropdown_steps'] = array( 0, 3, 4, 5, 6, 7, 8, 9 , 10);
            } 
            //  In cart
            else {
                // Cart's 'min_value' is 0
                $args['max_value'] = 10; 
                $args['step'] = 1; 
                $args['min_value'] = 3;
            }
        return $args; 
    }
    add_filter( 'woocommerce_quantity_input_args', 'my_quantity_input_field_args', 10, 2 );

    But that 2nd solution: When we click add to product when the quantity is 0 on product page, the quantity field on cart is 3 & the price is for 1 product .. while we need when we click on product page add to cart when the quantity field is 0 to reflect in the cart quantity field is 3 and the price of 3 products not just 1.

    So the issue in the 2nd solution is that it reflects the price of only 1 product not the 3 as it appears in the quantity.

    What we need to achieve from any of the above solutions, is when we click add to cart on the product page and quantity is 0, to reflect with 3 & show the price of 3.

    Sorry for complexity

    Stay Safe for you & your family

    Best Regards

    Plugin Author moiseh

    (@moiseh)

    It’s very complex situation sir i’m unfortunately not able to help at moment.
    Maybe it’s a good idea to hire a WooCommerce specialist to help you with.
    Regards

    Thread Starter magedmoh94

    (@magedmoh94)

    Hi moiseh,

    We are very sorry that you feel that .. its our problem and we have to solve it .. so we searched the internet to try to find the cause

    we already identified the issue that we need to make an ajax call update to the price with the quantities after the product is added to the cart & returning the new $args by using the 2nd solution to make the price the right corresponding value to the quantity added.

    So in the 2nd solution can you help us with a line of code to include it in the 2nd solution to make it call the ajax update cart you have in your plugin after adding the products to the cart ?, just updating the cart after returning the new $argswill fix the price issue to match the quantity added.

    Is it the code to force ajax update after returning the new $args ?: do_action( 'woocommerce_after_cart_item_quantity_update', $cart_item_key, $quantity, $old_quantity );

    if you feel that question our of your hands and feel as a custom request you can skip it .. you already helped us thousands times before to make this great plugin compatible with every part we use we already thankful for you.

    have a nice day & stay safe for you and your family

    Best Regards

    • This reply was modified 4 years, 1 month ago by magedmoh94.
    Plugin Author moiseh

    (@moiseh)

    Hello,

    I didn’t mean that is your problem i just think that is difficult to give a precise answer without more in-depth look and maybe a more dedicated assistance ?? – The first issues you requested i find easy to reproduce here but the other ones, unfortunately no

    I never tested this callback ( woocommerce_after_cart_item_quantity_update ) but it seems that is not exactly what you looking for, it will not force AJAX update after add to cart (if it’s what you’re asking).

    I’m sorry by now it’s difficult to me give more precise answers because it’s a bit abstract to me without looking into your shop, testing the hooks, if it’s doing what expected etc. I can do paid customisations if needed ping me at https://pluggablesoft.com/contact

    Regards

    Thread Starter magedmoh94

    (@magedmoh94)

    Hi Moiseh,

    You are a great man .. you always do what you can do for us and we really appreciate that sir.

    Thank you so much for the great support.

    We will contact you shortly for that customization

    Stay Safe & Best Regards

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘little Compatibility issue with dropdown menu’ is closed to new replies.