WooCommerce display add to cart without default selection - wordpress

I need to display the "add to cart button" without choosing default selection values with variations.
A customer can select the variable from the dropdown variations and reset the values back and the "single_variation_wrap" should always be visible.
I tried to remove "display:none" under variables.php but it didn't do the trick.
Could anyone help?

See the answer here
"WooCommerce: always showing add-to-cart button even before variation is selected"

This should work:
You can deregister the current add to cart variation Javascript, copy and paste this script into your theme directory and enqeue this new one. Here you can remove the slidedown feature and it will always show.
Caveat
When woocoomerce push a new release, you will have to check the changlog to see if anything has changed inside add-to-cart-variation.min.js

Related

Why would WooCommerce Product Attributes disappear on save

I have a WooCommerce store that has products with attributes that are associated with variations. When I save products, the attributes disappear (and therefore the associated variations do, too). When I re-add the attributes and save the product again, the variations come back as they were. (Note that this means attributes don’t always disappear - only when they’re not manually added before saving. )
No errors are logged.
I'm looking for some insight as to why this would happen.
I had the same issue since I use Ozisti theme for my site, too.
The workaround was to do NOT USE "Save attributes" button on product page. To save attributes changes USE "Update" (product page - on the top/right of the page).
The problem has been solved with Ozisti ThemeREX support team. They sent me new files:
wp-content/plugins/trx_addons/components/api/woocommerce/woocommerce-extended-attributes.php
wp-content/plugins/trx_addons/includes/plugin.wp.php
and now it works fine.
Regards, Jacek
I think I had a similar problem.
WordPress 5.1.1
WooCommerce 3.5.7
Ozitsi 1.0.2 Theme by ThemeRex (here was the problem)
Solution summary: Add attribute, add options, press SAVE ATTRIBUTES (attribute row folds) -> UNFOLD IT immediately - if you don't see options inserted a second ago into the Comboselect field read on.
In my case plugin ThemeREX Add-ons (shipped with Ozisti theme) was the issue. It added extra attribute types, so I could turn variations between dropdown select, image, color and button types.
After few hours of debugging I noticed that when attribute was set to one of the new types, UPDATING PRODUCT did erase all added attributes -> and by extension variations.
After ADDING ATTRIBUTES again (without SAVE ATTRIBUTES button - just adding attributes and UPDATING product) all was back in place.
Notice: when you SAVE ATTRIBUTES the row with options closes, the variations become available. But when I opened the attribute row after all AJAX saving was done it turned out that there were no OPTIONS placed in this Wordpress combo select of attribute I just edited.
So on UPDATING PRODUCT WooCommerce saved empty attribute options into DB.
This might not be perfect solution but I solved this by modifying WooCommerce's meta-boxes-product.js
I commented out line 465 and added another line to close the row:
$( '.product_attributes' ).html( response.data.html );
$( '.product_attributes .woocommerce_attribute.open .handlediv' ).trigger('click');
I didn't trace everything to the roots but makinkg it work for this single project is good enough for me at this point.
You probably use other plugins then me, but maybe they do something similar to my case.
So try to SAVE ATTRIBUTES and then immediately open attribute row again and check if selected options are inserted.. if not.. try my solution.
This Happen to me This Year. I was debugging my store for 3 days.
Solution:
I load a css file on Wordpress back office with these lines:
.save_attributes, .save-variation-changes {
display:none !important;
}
This makes WooCommerce Hide 2 buttons.
Save Attribute and Save Variation. So clients will be forced to use the update button in the product page. I'm still not sure if this is a Woocommerce bug or other plugin but for some reason, if I pressed one of these 2 buttons I would lose all my variations.
I have similiar solution with #Maciej Dejewski using Woocommerce v3.6.5.
On file /plugins/woocommerce/assets/js/admin/meta-boxes-product.js or /plugins/woocommerce/assets/js/admin/meta-boxes-product.min.js (depends on your admin page calling the javascript - you can check it via inspect element)
But instead adding line
$( '.product_attributes .woocommerce_attribute.open .handlediv' ).trigger('click');
Just commented out this
$( '.product_attributes' ).html( response.data.html );
Working fine for me
Here's the screenshot
Hope this would help!
After debugging for a hour, it turns out that my variations only disappear when not each attribute is selected. However, some of my product's attributes have between 10 and 150 entries..so that is the downside when using this method.

WooCommerce Variation Try or Buy with ACF

I have a strange request that I don't know how to approach or get working with WooCommerce.
On the product page we have two options. Buy or Try this product.
So generally "Buy" for say, $49.95 would include shipping and you can checkout as normal.
But "Try" for say $6.95 - that $6.95 is your shipping charge to try it, and the full product price at the end of the 15-30 days is the $49.95.
When you select Try you need to agree to some terms and conditions before you can add it to the cart.
So I think Advanced Custom Fields to add a conditional WYSIWYG to add in some specific information and make the Checkbox required to add to cart. I'm not required to think about the billing side of things just to get this Try or Buy working on a product page.
How the heck do I do this?
This is pretty straight forward with ACF.
Create a field like you mentioned as a wysiwig editor for the content.
Create a checkbox field and set Required: to yes. Add conditioning to hide it unless the checkbox from clicking the trial button is populated.
Create a checkbox field, that you will use to create the Trial button. Restyle it to be a button.
Now on the try button, add some JS in order to make a popup appear.
They read the popup and check the box.
Do an if statement to check if the checkbox has accept or whatever you set the checked yes value to. If it is equal to that value, add a styling or class to the try button to make it disappear. Remove styling or a class off an extra button that allows you to then get the product buy pressing it.
This seems like it would work, you'd then just need to figure out how to get the product charge to differ. Perhaps when they click that button it populates a hidden coupon field which applies a discount to the basket making it the amount you want the cost to be? Or it changes the value they have to pay. I will let you figure that one out.

Changing variantions inside cart on woocommerce

Hello I have a shop that needs to have variation selection inside a cart. When a user tries to change item variation page should refresh and update current item.
The problem is I cannot find a function that does that. I was thinking to use
WC()->cart->add_to_cart($product_id,$quantity) but this one does not fit my needs. Also I tried to change variation key inside.
WC()->cart but that did not work either. How can I solve this problem?
I've found it myself
If you want to add variation just enter it inside third field like
WC()->cart->add_to_cart($product_id,$quantity,$variation_id)

How to remove default dropdown Select option in Wordpress Contact Form Manager plugin

I'm using the Wordpress Contact Form Manager plugin. If I set a dropdown's element Default drop down value to some value that value does appears selected as I've set it. The problem is when I click on the dropdown to expand it, the additional Select option appears as shown on the image, and I can't seem to find where could I customize this. I went through their FAQ and googled but no help.
As it seems the option to edit this really doesn't exist via the plugin admin panel and in order to remove the additional Select option you have to edit the create-contact-form.php starting on line 1006 and comment the code out:
if($formElementDetail->client_view_multi_select_drop_down != 1){
//$replace = $replace.'<option value="">Select</option>';
}
You can of course comment (or remove) the whole if case. Hope this will help someone.

WooCommerce - no confirmation after adding product to cart

I'm not sure it's meant to be like this, but when I click the 'Add to cart' button on a product (when viewing a page of products), no visual confirmation is given to the user.
Am I missing a JS file? Or maybe I need a div with a specific ID in my HTML for the message to be displayed in? Or do I need to create my own JS callback method to handle when the product has been added?
I've researched this, and there's surprisingly little info on it (so maybe I broke something?).
I have WC's "Enable AJAX add to cart buttons on product archives" option ticked, and I can confirm that products are actually being added to the cart - the user just doesn't know anything about it!
Thanks in advance.
Problem solved - I had unticked WC's "Enable WooCommerce CSS styles". It should come with a warning in my opinion! :)

Resources