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

Okay
  Public Ticket #2768281
Auto(de)select Product by choosing variation
Closed

Comments

  • Laura started the conversation

    Hello Support,

    I would like to know how to select or deselect the respective product when clicking on a variation.
    Many customers overlook the fact that the 2nd separate click on the 1st. checkbox is required.

    Best regards,

    Laura



  •  767
    Janilyn replied

    Hi Laura,

    Thanks for contacting us here.

    Currently, our plugin doesn't have this feature. I will add a note to the backlog of our developer's dashboard to request this. If any developer of our team takes this in and releases an update for that, I will notify you.

    Best regards.

    Janilyn T. - WPClever Support Agent

  • Laura replied

    This should actually be a fundamental part of the plugin and even more so for the premium customers, as the variations only comes with the premium version. 

    As many Customers clicks on the Variations WITHOUT SELECTING THEM, we dont have any benefit with using your Plugin.

    Especially on mobile, your Plugins makes it nearly impossible to get that you have to make these extra clicks to REALLY select the desired extra products.

    Even worse, we have already had to completely recreate 2 orders and manually include the respective additional products. The duration of communication with customers and the resulting confusion are very counterproductive.

    We are considering disabling the plugin until you provide this obviously basic needed feature.

    We hope for assistance soon.

  •  767
    Janilyn replied

    Hi Laura,

    Thanks for your understanding.

    I have consulted with our head developer so that he can consider this feature soon.

    Best regards.

    Janilyn T. - WPClever Support Agent

  •  1,222
    Dustin replied

    Hi Laura,

    I'm so sorry for the late reply!

    Please add the below custom code (How to add custom code?)

    add_action( 'wp_footer', 'woobt_auto_checkbox_js' );
    function woobt_auto_checkbox_js() {
        ?>
        <script type="text/javascript">
          jQuery(document).on('found_variation', function(e, t) {
            var _this_product = jQuery(e['target']).closest('.woobt-product');
            if (_this_product.length) {
              _this_product.find('.woobt-checkbox').prop('checked', true).trigger('change');
            }
          });
          jQuery(document).on('reset_data', function(e) {
            var _this_product = jQuery(e['target']).closest('.woobt-product');
            if (_this_product.length) {
              _this_product.find('.woobt-checkbox').prop('checked', false).trigger('change');
            }
          });
          jQuery(document).on('woovr_selected', function(e, selected, variations) {
            var _this_product = variations.closest('.woobt-product');
            if (_this_product.length) {
              var _purchasable = selected.attr('data-purchasable');
              if (_purchasable === 'yes') {
                _this_product.find('.woobt-checkbox').prop('checked', true).trigger('change');
              } else {
                _this_product.find('.woobt-checkbox').prop('checked', false).trigger('change');
              }
            }
          });
        </script>
        <?php
    }

    Then when choosing a variation, this checkbox auto was checked.

    Best regards,
    Dustin

  •  1
    Antonia replied

    Hello,

    I'm wondering if the code should work with the WPC Grouped Product Plugin? If so it doesn't seem to work on my website.  Would be great if I could use it too.

    Antonia

  •  1,222
    Dustin replied

    In the Grouped plugin, please set the default quantity as zero https://www.screencast.com/t/RPuiTkkwVCrd and it wasn't checked by default.

    Best regards,
    Dustin

  •  1
    Antonia replied

    The default quantity is set to zero already. Nothing was checked by default.

  •  1,222
    Dustin replied

    Sorry about that!

    For this request "select or deselect the respective product when clicking on a variation", please add the below custom code (How to add custom code?)

    add_action( 'wp_footer', 'woosg_auto_checkbox_js' );
    function woosg_auto_checkbox_js() {
        ?>
        <script type="text/javascript">
          jQuery(document).on('found_variation', function(e, t) {
            var _this_product = jQuery(e['target']).closest('.woosg-product');
            if (_this_product.length) {
              _this_product.find('.woosg-checkbox').prop('checked', true).trigger('change');
            }
          });
          jQuery(document).on('reset_data', function(e) {
            var _this_product = jQuery(e['target']).closest('.woosg-product');
            if (_this_product.length) {
              _this_product.find('.woosg-checkbox').prop('checked', false).trigger('change');
            }
          });
          jQuery(document).on('woovr_selected', function(e, selected, variations) {
            var _this_product = variations.closest('.woosg-product');
            if (_this_product.length) {
              var _purchasable = selected.attr('data-purchasable');
              if (_purchasable === 'yes') {
                _this_product.find('.woosg-checkbox').prop('checked', true).trigger('change');
              } else {
                _this_product.find('.woosg-checkbox').prop('checked', false).trigger('change');
              }
            }
          });
        </script>
        <?php
    }

    Best regards,
    Dustin

  •  1
    Antonia replied

    Great, it works now. Thank you!

  •  1,222
    Dustin replied

    You're welcome!smile.png

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

    Best regards,
    Dustin