helgatheviking / add-to-cart-form-shortcode Goto Github PK
View Code? Open in Web Editor NEWAdd [add_to_cart_form] shortcode that display a single product add to cart form for WooCommerce
Add [add_to_cart_form] shortcode that display a single product add to cart form for WooCommerce
Hi. Thanks for sharing this.
Could you explain how to use this on my website?
I already have a child theme installed.
I would like to replace the current shortcode [add_to_cart] with yours, using the same name.
To see if so the quantity field will be displayed in my products listed by ContentViews.
But I don't know how to insert this code, I tried to add to the functions.php file but it didn't work.
We are intentionally killing the current $wp_query
here but that means that we have no way to detect what page we're currently on when we are inside the shortcode... making any conditional logic (like is_checkout()
) impossible.
Hi. We just had a client report that the shortcode isnt working correctly with variable products all of the sudden.
Inside the variations_form div you start to see malformed or escaped code?:
`<span class=""woocommerce-Price-amount" amount"="">$</span>568.00</bdi></span></span>","sku":"EVC3AA0A2E1A1","variation_description":"","variation_id":112,"variation_is_active":true,"variation_is_visible":true,"weight":"15","weight_html":"15 lbs","woofs_image":"<img width=""300"" height=""300"" src=""https://evocharge.com/wp-content/uploads/2021/01/3-1-300x300.jpg"" class=""attachment-woocommerce_thumbnail" size-woocommerce_thumbnail"="" alt="""" decoding=""async"" loading=""lazy"" srcset=""https://evocharge.com/wp-content/uploads/2021/01/3-1-300x300.jpg" 300w,="" https:="" ="" evocharge.com="" wp-content="" uploads="" 2021="" 01="" 3-1-1024x1024.jpg="" 1024w,="" 3-1-150x150.jpg="" 150w,="" 3-1-768x768.jpg="" 768w,="" 3-1-600x600.jpg="" 600w,="" 3-1-100x100.jpg="" 100w,="" 3-1-50x50.jpg="" 50w,="" 3-1.jpg="" 1080w"="" sizes=""(max-width:" 300px)="" 100vw,="" 300px"="">","display_price_cents":56800},{"attributes":{"attribute_pa_cable-length":"25-cable"},"availability_html":"","backorders_allowed":false,"dimensions":{"length":"16","width":"15","height":"11"},"dimensions_html":"16 ร 15 ร 11 in","display_price":599,"display_regular_price":599,"image":{"title":"EVSE-32-Amp-Home-Charger","caption":"","url":"https://evocharge.com/wp-content/uploads/2021/01/3-1.jpg","alt":"EVSE-32-Amp-Home-Charger","src":"https://evocharge.com/wp-content/uploads/2021/01/3-1-600x600.jpg","srcset":"https://evocharge.com/wp-content/uploads/2021/01/3-1-600x600.jpg 600w, https://evocharge.com/wp-content/uploads/2021/01/3-1-300x300.jpg 300w, https://evocharge.com/wp-content/uploads/2021/01/3-1-1024x1024.jpg 1024w, https://evocharge.com/wp-content/uploads/2021/01/3-1-150x150.jpg 150w, https://evocharge.com/wp-content/uploads/2021/01/3-1-768x768.jpg 768w, https://evocharge.com/wp-content/uploads/2021/01/3-1-100x100.jpg 100w, https://evocharge.com/wp-content/uploads/2021/01/3-1-50x50.jpg 50w, https://evocharge.com/wp-content/uploads/2021/01/3-1.jpg 1080w","sizes":"(max-width: 600px) 100vw, 600px","full_src":"https://evocharge.com/wp-content/uploads/2021/01/3-1.jpg","full_src_w":1080,"full_src_h":1080,"gallery_thumbnail_src":"https://evocharge.com/wp-content/uploads/2021/01/3-1-100x100.jpg","gallery_thumbnail_src_w":100,"gallery_thumbnail_src_h":100,"thumb_src":"https://evocharge.com/wp-content/uploads/2021/01/3-1-300x300.jpg","thumb_src_w":300,"thumb_src_h":300,"src_w":600,"src_h":600},"image_id":10192,"is_downloadable":false,"is_in_stock":true,"is_purchasable":true,"is_sold_individually":"no","is_virtual":false,"max_qty":"","min_qty":1,"price_html":"<span class=""woocommerce-Price-amount" amount"="">$</span>599.00</bdi></span></span>","sku":"EVC3AA0B2E1A1","variation_description":"","variation_id":113,"variation_is_active":true,"variation_is_visible":true,"weight":"17","weight_html":"17 lbs","woofs_image":"<img width=""300"" height=""300"" src=""https://evocharge.com/wp-content/uploads/2021/01/3-1-300x300.jpg"" class=""attachment-woocommerce_thumbnail" size-woocommerce_thumbnail"="" alt="""" decoding=""async"" loading=""lazy"" srcset=""https://evocharge.com/wp-content/uploads/2021/01/3-1-300x300.jpg" 300w,="" https:="" ="" evocharge.com="" wp-content="" uploads="" 2021="" 01="" 3-1-1024x1024.jpg="" 1024w,="" 3-1-150x150.jpg="" 150w,="" 3-1-768x768.jpg="" 768w,="" 3-1-600x600.jpg="" 600w,="" 3-1-100x100.jpg="" 100w,="" 3-1-50x50.jpg="" 50w,="" 3-1.jpg="" 1080w"="" sizes=""(max-width:" 300px)="" 100vw,="" 300px"="">","display_price_cents":59900}]">
Cable Length |
Choose an option
|
You can view that on the live site here:
https://evocharge.com/home-charging-solutions/
(click buy now under evse or 32 amp ievse).
We recently updated to wp 6.2 and the latest woo. Site was working fine before that I believe. Any idea what is going on here?
When an add to cart button is clicked, the page reloads but there's no "this product has been added" notification. Pages/posts probably don't have the wc_print_notices()
function and not sure how to add that.
This should do nothing if WC is not active.
Hi,
Great code but it doesn't seem to work for yith Booking and Appointment for WooCommerce.
Any hack can be done?
Thank you.
X.
could possibly add a parameter to toggle ajax? typically an add to cart button needs to have add_to_cart_button
and ajax_add_to_car
t and the data-product_id
attribute for it to automatically have the WooCommerce ajax add to scripts kick in.
Unsure how quantity inputs would be handled (possibly add data-quantity
to the button. and finally, may not work well with custom product types.
When I try to activate the plugin, I get error "WooCommerce has detected that some of your active plugins are incompatible with currently enabled WooCommerce features. Please review the details - (/wp-admin/plugins.php?plugin_status=incompatible_with_feature.
The action to redirect is suppressed here: https://github.com/helgatheviking/add-to-cart-form-shortcode/blob/master/wc-add-to-cart-form-shortcode.php#L156
This worked well for me to reload the same page. But in cases where uses want to redirect to the cart, it prevents that from occurring.
When submitted, multiple shortcodes on the same page all get the same posted value.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.