RobertSpread / spreadcart

simple plugin to display a cart for the spreadshop everywhere on your domain
1 stars 1 forks source link

Has SpreadShirt released a better approach yet? #38

Open jtlapp opened 5 years ago

jtlapp commented 5 years ago

Hey Robert,

I'm fixing up my spreadshirt site for all the changes that have been made in the past two years. In particular, I notice that it's now possible to refer to a page on SpreadShirt for managing the shopping cart. That makes for a great "Cart" link on my site, but I still need to show the number of items in the cart.

Should I modify this plugin for this simpler purpose, or does SpreadShirt now provide a plugin that I can use, making this plugin completely obsolete?

Thanks for your help!

jtlapp commented 5 years ago

I've revised the plugin as follows, but haven't checked it in to my repo yet:

  1. Clicking the shopping cart icon goes to a new page at a specified URL. I ripped out the shopping cart overlay, as it's too much effort to maintain. The overlay is unnecessary now that SpreadShirt provides a means to load just the shopping cart into a frame.
  2. In order to ensure that the plugin survives future changes to the embedded shop UI, I've hardcoded it to retrieve the current basket every single time that the user clicks on something in the embedded shop or changes some field value. You can specified delays and retry counts to reduce load on the server and SpreadShirt API.
  3. To simplify the code I completely delegate providing the shopping cart icon to the application. Now there is only one code path to maintain instead of two. Of course, the plugin can come with a default icon to simply things, but the user can easily change it to any other rendering approach.
  4. I removed the language strings. Now that there's no overlay cart, there's no need for them.

The server side code remains unchanged. Otherwise, the amount of code has halved.

Given that the new plugin is not backwards compatible and no longer provides shopping cart functionality, should I make it available to spreadcart, or should I post it as a new repo of my own? I'm inclined to also post additional advice (in the README) about creating custom shops.

jtlapp commented 5 years ago

SpreadShirt wouldn't happen to have provided a more efficient way to communicate item count changes to a shopping cart plugin, has it? My new plugin polls SpreadShirt pretty much every time the user does anything in the embedded shop. Moreover, if the poll results in a basket having the same number of items as before, I don't know whether I polled too soon or whether the basket wasn't changed, so I poll again with several retries until eventually deciding it really didn't change.