bigcartel / dugway

Easily build and test Big Cartel themes.
https://developers.bigcartel.com/api/themes
MIT License
149 stars 22 forks source link

dugway returns (via ajax) a completely different cart object from big cartel #112

Closed pjv closed 10 years ago

pjv commented 10 years ago

tl;dr : dugway's cart json actually matches the documentation, but the cart that big cartel returns has many fewer properties (excluding for example subtotal and country).

i believe that you can see the difference if you put an item into the cart in dugway and then from the cart page, just add ".js" to the end of the url, then do the same thing on the cart page in big cartel and compare the structure of the returned json.


context: i am using the ajax API detailed here to build a cart page that can update quantities and dollar amounts without requiring a page reload.

i have been working on dugway and got as far as i could with everything working as expected. when it came time to start working on the ability for the user to choose their shipping country and have that then update the shipping amount, i needed to move the theme from dugway to big cartel since dugway does not support the shipping calculations (as far as i understand).

when i moved the theme to big cartel, a bunch of stuff that was working perfectly under dugway stopped working. in debugging it i have discovered that the cart object that dugway returns is a very different object than the one that big cartel returns.

am i missing something?

pjv commented 10 years ago

If any of you dugway / bigcartel gurus out there have any thoughts on this, I'd love to hear them - this is a total show-stopper for my current project.

nickendle commented 10 years ago

Hey @pjv -

The issues you're experiencing are due to the differences in our two checkout options - PayPal vs. Stripe (our new 'seamless checkout' option). With the PayPal checkout, customers have the ability to select their country and enter a discount code on the Cart page, and with seamless checkout that functionality is moved into a separate Checkout area.

To have a Big Cartel store work the same as Dugway, you can head to the Store > Settings > Checkout page in the Big Cartel admin and make sure PayPal checkout is enabled. You'll then want to take advantage of the cart.discount.enabled and cart.shipping.enabled variables when figuring in the cost of the order. Here's some code that puts these variables in context, with our Sidecar theme: https://github.com/bigcartel-themes/sidecar/blob/master/source/cart.html#L58-L132

Apologies for the troubles you've been experiencing with Dugway, and thanks for posting about these issues -- we're certainly paying attention and have plans to make this process less painful down the road.

outerim commented 10 years ago

@pjv what @deadformat said is correct. I will add a bit of detail. The differences you're seeing on seamless are intentional (perhaps with the exception of subtotal, may need to look at that more). In essence the idea is that stores/themes don't need to worry about as many features (discounts, shipping, and in the future tax or other details) because the seamless checkout system handles that for them. We intend the transition to be mostly transparent to people and ultimately everyone will transition to seamless checkout as it gets more features and supports paypal in addition to stripe, etc.

Perhaps you could describe what you're trying to accomplish or whether you explicitly need to be able to add discounts on the js/store side of things regardless of whether seamless is in use or not. For what it's worth the seamless checkout system itself uses an as yet undocumented but public API for it's work. It's conceivable that you could use it to add discounts or collect buyer information while still in the store if you know the person you are making the theme for will be using seamless checkout.

Also for the time being dugway's JSON responses and liquid API are designed to mimic the non-seamless setup since that's effectively the superset of features. Once everyone is using seamless we will likely change that.

pjv commented 10 years ago

thanks for getting back to me.

paypal is definitely not an option for the store i am working on.

wow, i completely missed the documentation on the seamless checkout where it says that the shipping country and discount inputs are removed from the cart page. man, i have been busting my butt on that stuff for nothing.

i can see what changes i need to make now.

just to clarify how the shipping cost calculation works - the seamless checkout will still use the amounts defined per product per country in the back end and apply the same logic of starting with the most expensive "alone" shipping cost and then adding on all the "with others" costs for the remaining items in the cart, right?

outerim commented 10 years ago

@pjv correct the shipping calculations are all handled by the seamless checkout system for you. The intention was to simplify things for theme designers in general :) Sorry if the documentation wasn't more clear. Any suggestions on how to improve it are welcome

pjv commented 10 years ago

@outerim the theme i am building is a one-off for a store that is definitely using seamless checkout.

what i have been trying to do is create an all-ajax cart page that lets the user see their total cost (subtotal + shipping) without any page reloads. here is a screenshot of the cart as it runs under dugway:

image

if you change the quantities or delete an item (which makes the line disappear with a lovely css animation), the subtotal and total will update immediately. i was working on making the shipping cost appear and update when the user selects or changes the shipping country. i could just get rid of that concept and just use the seamless cart object's "total" for the subtotal, but if there is a way to exploit your undocumented seamless api to be able to do the shipping thing that i am trying to do, i think it would make for a better user experience if they could see the total cost before they click the checkout button.

outerim commented 10 years ago

Considering the use case I think it might be preferable to just remove the feature for now. That is unless you're up for reverse engineering the checkout api (which shouldn't be all that bad, the seamless app is just sending CORS requests.) At this point we wouldn't be able to help much with that process.

pjv commented 10 years ago

thanks @outerim, as i am on a bit of a deadline, i'll just get rid of the shipping selection on the cart page and move on. will also be looking forward to seeing eventual documentation for the seamless checkout api for the future of this theme and potential others.