Home Forums Basel – Premium Template Variations issue with default form values are sold out scenario

This topic contains 12 replies, has 2 voices, and was last updated by Artem Temos Artem Temos 1 week, 4 days ago.

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

    tiantzer
    Customer

    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.

    Private Content Hidden
    #131074

    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
    Customer

    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

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

    #131162

    tiantzer
    Customer

    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

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

    #131249

    tiantzer
    Customer

    Hi~

    Private Content Hidden
    #131250

    tiantzer
    Customer

    wordpress login address:

    Private Content Hidden
    #131255

    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
    Customer

    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

    Sorry, move it to document ready section there.

    #131459

    tiantzer
    Customer

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

    😀

    #131470

    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.