Home Forums Basel support forum Variations issue with default form values are sold out scenario

Variations issue with default form values are sold out scenario

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #131064

    tiantzer
    Participant

    Hello great Xtemos team,
    I hope you all well.

    I’v experience a issue which is the variable product had set a default form values while the default values are sold with “Do not allow” for backorders,

    I cannot select another variation or add another variations to shop cart and will showing
    “Please select some product options before adding this product to your cart.”.

    The solution is that I need to click clear first, after that I can able to select other variations with stocks. I think it’s important with people need set their default form values and user experience are effected.

    I’d set the default form values with white color and it
    ‘s already sold out with not allow for backorder option, please visit the link below and provide the solutions.

    Thanks.

    #131074

    Artem Temos
    Keymaster

    Hello,

    Could you please check how it works with some default WordPress theme like twentysixteen to understand is it our theme issue or not?

    Regards

    #131159

    tiantzer
    Participant

    Hi,

    It’s normal with default WordPress themes because those default themes doesn’t preselect variations even have had set default form values.

    Thanks.

    #131160

    Artem Temos
    Keymaster

    Sorry, what do you mean? The default variation is a WooCommerce functionality and should work with a standard theme as well.

    #131162

    tiantzer
    Participant

    Hello,

    I mean that issue does not happen with WordPress default themes but it’s happen with BASEL theme.
    Because the default theme does not preselect variation which is sold out, but BASEL theme still preselect variation while the default form values had been sold out and cause that issue.

    I’m apologize my english.

    #131247

    Artem Temos
    Keymaster

    Could you please send us your admin and FTP access so we can check what is wrong?

    #131249

    tiantzer
    Participant

    Hi~

    #131250

    tiantzer
    Participant

    wordpress login address:

    #131255

    Artem Temos
    Keymaster

    Try to add the following code snippet to the Custom JS area in Theme Settings to fix this issue.

    jQuery('.variations_form').each(function () {
    	var $variation_form = jQuery(this);
    
    	$variation_form.on('update_variation_values', function (e) {
    		// Count available options.
    		$variation_form.find('.variations select').each(function () {
    			var $select = jQuery(this);
    			var attached_options_count = $select.find('option.attached').length;
    			var selected_attr_val = $select.val() || '';
    			var selected_attr_val_valid = true;
    
    			// Check if current selection is in attached options.
    			if (selected_attr_val) {
    				selected_attr_val_valid = false;
    
    				if (0 !== attached_options_count) {
    					$select.find('option.attached.enabled').each(function () {
    						var option_value = jQuery(this).val();
    
    						if (selected_attr_val === option_value) {
    							selected_attr_val_valid = true;
    							return false; // break.
    						}
    					});
    				}
    			}
    
    			// Choose selected value.
    			if (selected_attr_val) {
    				// If the previously selected value is no longer available, fall back to the placeholder (it's going to be there).
    				if (!selected_attr_val_valid) {
    					$variation_form.find('.basel-swatch[data-value=' + selected_attr_val + ']').removeClass('active-swatch');
    				}
    			}
    
    		});
    	});
    });

    Also, remove the code you have there since it is broken and may cause problems with the fix http://prntscr.com/oaelov

    #131256

    tiantzer
    Participant

    Hi,

    I have add that code to the custom js and remove another codes but didn’t works.

    Attachments:
    You must be logged in to view attached files.
    #131264

    Artem Temos
    Keymaster

    Sorry, move it to document ready section there.

    #131459

    tiantzer
    Participant

    It’s works for me now, thanks for help.

    😀

    #131470

    Artem Temos
    Keymaster

    Great, you are welcome!

Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘Variations issue with default form values are sold out scenario’ is closed to new replies.