Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3666512
list view - activation checkmark gets acticvated when quantity is increased
Open

Comments

  •  4
    Eric started the conversation

    hi, my customers complaint that they have to check twice if they want to buy products at our shop. They have to choose quantity and then activcate the checkmark. is it possible that the checkmark gets automatically activated when quantitiy is bigger than zero? or that the customer only has to select the quantitiy they want and then is able to add to cart?Jetzt Ticket sichern! - Affenkäfig Festival 2024 in Mendig (affenkaefig-festival.de)

  •  4
    Eric replied

    see screenshot

    Attached files:  Screenshot 2024-06-13 222437.png

  •  1,226
    Dustin replied

    Hi Eric,

    Please add the custom code below. (How to add custom code? ↗):

    add_filter( 'wooco_component_product_selected', function ( $selected, $component_product, $component ) {
        if ( isset( $component['qty'] ) && ( $component['qty'] > 0 ) && isset( $component['multiple'] ) && ( $component['multiple'] === 'yes' ) ) {
            $selected = true;
        }
        return $selected;
    }, 99, 3 );
    add_action( 'wp_footer', function () {
        ?>
        <script type="text/javascript">
          (function($) {
            $(document).on('change', '.wooco_component_product_qty_input', function() {
              var $item = $(this).closest('.wooco_component_product_selection_item');
              if ($item.data('purchasable') === 'yes') {
                if ($(this).val() > 0) {
                  if (!$item.hasClass('wooco_item_selected')) {
                    $item.trigger('click');
                  }
                } else {
                  if ($item.hasClass('wooco_item_selected')) {
                    $item.trigger('click');
                  }
                }
              }
            });
          })(jQuery);
        </script>
        <?php
    }, 99 );

    Then the products will be selected automatically when the quantity is bigger than zero.

    Best regards,
    Dustin

  •  4
    Eric replied

    Dustin, you are great :) You really need to add this feature in the upcoming releases. Thanks, Eric

  •  1,226
    Dustin replied

    We'll check and implement it soon.

    If you are satisfied with our plugin and support, please reward it with a full five-star ★★★★★ rating.
    https://wordpress.org/support/plugin/wpc-composite-products/reviews/?filter=5
    Thank you in advance! ♥

    Best regards,
    Dustin