Drupal Commerce Ajax cart with added fields - drupal

Sorry for the really bad title but wasn't sure how to describe my problem in 10 words.
I have drupal commerce and have made a view that displays the cart contents on top of the checkout page.
Quantity is a text field so it is editable and I have an update button. Unfortunately when I press the update button, naturally the whole checkout page tries to submit. Is there a way to intercept the update button and just refresh the cart with ajax?
Moreover, if I can do that, I want a number of text fields (as many as the quantity number entered) to appear underneath the cart so the user can enter different values on each of them (each referring to the products about to be bought).

Drupal Commerce Cart does this - sort of.. http://drupal.org/project/dc_cart_ajax
It works fine on the cart page, though I too am trying to combine these pages to cut down on the 'checkout steps'. Though it is the same view as the /cart page and I get an ajax refresh indicator it doesn't actually update the cart on the checkout page.
There is a issue related to that, you can subscribe: http://drupal.org/node/1443470

You can disable the Shopping cart contents using the checkout settings. Modify the Shopping Cart View to add a block display and add modify the contextual filter by providing default value using PHP:
if (arg(0) == 'checkout') return arg(1);
else return null;
Add the new Shopping cart block dispplay only on the checkout page and here you go.

Related

Add continue shopping button at woocommerce store category

Help me I'm looking around, but I still don't find what I need, add another button on my woocomerce store page with the option to add to cart and continue shopping without leaving the page
Here's an example of what I need:

Remove Woocommerce add to cart message but keep updating cart amount

I'm using quick view pro by Barn2 for woocommerce and using this code to hide the add to cart message Hide Added to Cart message in Woocommerce which works fine, but in my case the cart amount is not updated until page refresh. So my question is how to modify the code so I be able to hide the message but allow the cart to be updated in the background without need of refresh? Thanks!

How to add front product page image upload and note textarea box in shopify

I need same like this website https://gopupsocks.com/product/custom-breast-cancer-fighter-socks/
How can I do it product page and cart page?
You can Google Shopify Documentation for two easy recipes to follow:
Line Item Properties (for the product pages)
Cart Notes and Attributes (for cart page and/or other places)
In both cases, you can use those to store any extra information you may want
Note that due to a quirk in Shopify, you won't have a cart to work with until the customer plays with the cart, or you use code to add/delete and item in the cart without them knowing. So be careful when trying the cart attributes out on the front page.

WooCommerce Add to Cart - Redirect to URL

I want to just show a simple add to cart button at the bottom of a page. I can do so by using shortcodes:
[add_to_cart id="99"] or [add_to_cart_url id="99"]
The problem is that I want to then go to another URL that is not related to WooCommerce. It has to be customized depending on the page we are on.
An example would be:
Intro Landing page (add to cart at bottom)
a. Action: adds product 99 to cart then redirects to #2.
Upsell page with 3 products on it
a. Action: adds one of the three products to the cart and redirects to #3.
Second Upsell page with 1 product on it
a. Action: adds the product to the cart and redirects to #4.
Checkout Page.
I was hoping there was a shortcode that I could use for Add to Cart and Redirect but can't find anything online. I have found a custom redirect option that woocommerce offers but it would set the redirect for all Add to Cart buttons.
I was thinking that there may be a way to create a function that expands the add to cart button shortcode so I can add a custom redirect URL to it.
For example: [add_to_cart id="99" redirect="../step2/"]
This can even be a URL that I can use in a link. I found that on this page under the section titled "URL: Add One Simple Product to Cart & Redirect to Any Page Afterwards" that says I should be able to just use:
href="http://yourdomain.com/your_custom_page/?add-to-cart=25"
It adds the product to the cart but then just redirects to the cart (I have AJAX add to cart buttons enabled).
Any ideas may help!
Thanks,
Matt
Using this works: http://yourdomain.com/your_custom_page/?add-to-cart=25
I just had to uncheck the box in WooCommerce Settings that says to go to cart when someone clicks add to cart and make sure AJAX links was checked

Unique issue with WooCommerce and hiding the add to cart button..?

We have a plugin that allows people to submit offers on products, and then the site owner can accept, counter, or decline offers, and you can negotiate back and forth until a price agreement is reached.
We are using the woocommerce_after_add_to_cart_button hook to add the offer button after the cart button.
We are getting lots of feedback that people want to leave the price of the product empty so that it simply display a price on the site, it won't display the Add to Cart button, but they do want it to display the offer button and allow that functionality.
If you set the price to 0.00, then it says FREE on the site, and still includes the add to cart button, so that's no good.
When left blank, though, the problem we run into is that when a customer clicks to buy a product from an accepted offer, WooCommerce keeps removing the item out of the cart because it says it's not purchase. This is happening because of the is_purchasable() function. With a blank price WC says the product is not purchasable, so it will automatically remove itself out of the cart, which it is indeed doing.
There is a hook available that allows us to force $purchasable = true for the product, but then of course that makes the Add to Cart button show up again, which doesn't make sense for this use-case.
So as it stands now we're at that point. We've got the system overriding $purchasable so that we can complete the checkout on a product with an empty price, but it's leaving the Add to Cart button, which allows the person to add the product at 0.00.
I'm stumped on the best way to hide to the Add to Cart button in this scenario..?? I would usually hide it by using that hook to make $purchasable = false, which takes care of it nicely, but in this case I can't do that because that's what keeps us from being able to purchase the product, of course.
Any information on a way around this would be greatly appreciated!
UPDATE
I found this tutorial for overriding core template files from a plugin: https://www.skyverge.com/blog/override-woocommerce-template-file-within-a-plugin/
So I think what we're going to try is to basically say "if $purchasable = false and $offers_enabled = true, then use these templates for the add to cart button."
Within our template we're doing nothing but commenting out the actual <button> element. This leaves all hooks in place, but hides our button.
Decent solution? Horrible idea?

Resources