First post here so I'll try to make it as good as possible.
For a WooCommerce / WordPress project, I'm trying to achieve the following. When the cart is empty, there should be a button displayed with the text "Return to store".
Now the button isn't the problem, I've added this with Elementor, now usually I use the JetEngine Dynamic Visibility option to show/hide things.
I've also done this with stock status. There I used the _stock option to only display when there are 5 or more in stock left.
So I'm trying something similar with the cart, whenever there are 1 or more items in the cart, this button needs to be hidden because whenever someone has 1 item in their cart we want them to proceed to the checkout and not return to the shop, because the average product bought per order is 1 for this particular shop.
But the one thing I can figure out is, what key do I need to use to check items in the cart?
I've been trying several options I found online but none seem to work.
Does anyone know how to do this?
Thanks!
Related
I have a custom form that users make various selections before being presented with products they can buy. I need to add some logic that if an input has been selected when the user adds a product to the cart, it will also add an additional product to the cart.
The input is 3 radio check boxes. Somehow I need to hook into the add to cart click and check the page to see if one of the radios has been selected and then add the appropriate product but I'm not sure where to start.
I know I'll need to have an action that runs something like:
WC()->cart->add_to_cart( 'product_id', 'quantity');
But I'm not sure how to hook into the initial add to cart click and how to check for the radios on the page.
Thank you for your help.
Not a lot of information to go off of here, but here is a few useful WooCommerce hooks to give you a starting point/ order of operations. When overriding any native action in WordPress or its plugins. You should use the hooks if available.
Add the radio inputs to the single product before the add to cart is added (hook):
add_action("woocommerce_before_add_to_cart_button", "your_input_render_function_here");
Add the new input data from the radio buttons to the cart item (filter):
add_filter("woocommerce_add_cart_item_data", "your_filter_function_to_capture_data_here");
Capture the data and render in cart (filter):
add_filter("woocommerce_get_item_data", "your_cart_render_function");
Finally, save the newly aquired data to the order (hook):
add_action("woocommerce_checkout_create_order_line_item", "your_function_to_add_to_order")
This is one of many directions you can take, depending on your requirements. I recommend giving it a shot, and if you still have issues return with an example of your code.
I'm developing a module that appears in the product page. This module consist of a checkbox which when is checked, shows a few inputs to be filled by the client and add an extra amount of, for example, 50.
How can I add this amount to the product cart? I'm using the hook hookActionCartSave to retrieve the cart but I can't update it adding the amount of 50.
The ideal is to reflex this concept like shipping costs but I'm stuck on how to change the product price or add a new concept when the checkbox is checked and client click "Add to cart" button.
Thank you!
I want to add a checkbox for the product to indicate if needs assemble or not,if yes, then more money will be charged. My products are shown as grouped style, like:
I am using a plugin called woocommerce extra product options, which can add the checkbox before "add to cart" button. As:
But I want to add the checkbox to each line of the simple products under the grouped product instead of only one; like:
I checked the documentaion, it says use following to hook the extra item in the code/page you want.
function my_custom_function(){
do_action("woocommerce_tm_epo");
}
add_action( 'woocommerce_before_add_to_cart_button','my_custom_function');
But I tried, it always shows only one before add to cart button regardless how many time "add_action('woocommerce_before_add_to_cart_button','my_custom_function');" it is called. How can I achieve my goal? Thanks in advance.
I also tried do_action("woocommerce_tm_epo"); only, but it is not showing anything. If I use do_action("woocommerce_tm_epo"), from screen I can see the space for the checkbox, but just showing the blank. I checked the firebug, I can see the checkbox is there, but for some reason is being hidden. I checked the corresponding CSS, find one place Visbility:hidden; after I changed it to visbility:visable. Still shows blank. Already sitting on the chair for this more than 13 hours, hope someone can help or provide helpful advices.
i am currently building a custom shopping cart to my website, it has all the items on the left and a slim view of the basket on the right with a list of all the items added plus a total value price. What i want is for the price and list to update when a user clicks on add to basket, but i don't want the page to reload, i know that AJAX can be used for this, but i was wondering if anyone had any tutorials that could show me some examples of being able to do this.
I am just getting a bit confused at the moment.
Thanks
there are many ajax shopping cart examples on internet, you can find them on google... for now here are some links for you
http://tutorialzine.com/2009/09/shopping-cart-php-jquery/
http://www.99points.info/2010/12/ajax-shopping-cart-with-jquery-and-php/
more than two hyperlinks are not allowed for me to post so i am posting hyperlinks without http :
net.tutsplus.com/tutorials/php/how-to-build-a-shopping-cart-using-codeigniter-and-jquery/
webresourcesdepot.com/ajaxed-sliding-shopping-cart-with-jquery/
I need to enable user to set quantity of products and add it to shopping cart in list of products page. there is only (add to cart) options without quantity field.
How can I fix this problem ?!!
It's not a "problem" that needs "fixing". You are after extended functionality. I'm guessing you want something like this
http://www.opencart.com/index.php?route=extension/extension/info&extension_id=3487