duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/simple-commerce
Other
143 stars 34 forks source link

Gateway Time-out #1034

Closed de-raaf-media closed 3 months ago

de-raaf-media commented 3 months ago

Description

Hi there, I just updated Simple-commerce by following the Upgrade Guide. Everything seems to be working (products list and show) . But adding a product to the cart results in a "504 Gateway Time-out", I compared my "add to cart" button with the one from the starter kit but I don't see any major differences.

Steps to reproduce

Click on add to cart. A request is sent to /!/simple-commerce/cart-items After a while the message "504 Gateway Time-out" appears.

I use the eloquent driver to store all entries. Including products and orders.

Environment

Statamic Addons: 4 Antlers: runtime Stache Watcher: Enabled Static Caching: Disabled Version: 4.32.0 PRO

Statamic Addons aerni/factory: 1.4.0 doefom/restrict: 0.1.0 duncanmcclean/simple-commerce: 6.0.10 statamic/eloquent-driver: 2.10.0

Statamic Eloquent Driver Asset Containers: file Assets: file Blueprints: file Collection Trees: file Collections: file Entries: eloquent Forms: file Global Sets: file Global Variables: file Navigation Trees: file Navigations: file Revisions: file Taxonomies: file Terms: file

duncanmcclean commented 3 months ago

Unfortunately, just "Gateway Timeout" doesn't give me much to go on. Are there any hints / stack traces in your log file?

de-raaf-media commented 3 months ago

I did some debugging and as far as I can tell it has something to do with the Store method in the CartItemController and then specific with the makeCart function that is called from the store function.

de-raaf-media commented 3 months ago

Unfortunately, just "Gateway Timeout" doesn't give me much to go on. Are there any hints / stack traces in your log file?

In the error log is see (anonymized):

2024/03/22 14:12:34 [error] 67179#1577365: *25 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: [domain].test, request: "POST /!/simple-commerce/cart-items HTTP/2.0", upstream: "fastcgi://unix:/Users/[user]/Library/Application Support/Herd/herd81.sock:", host: "[domain].test", referrer: "https://[domain].test/products/[slug]"

duncanmcclean commented 3 months ago

Can you try moving your orders & customers into Simple Commerce's database driver to see if that fixes it?

If you're using a database anyway, it probably makes sense to use SC's database stuff rather than keep using entries via the Eloquent Driver.

de-raaf-media commented 3 months ago

The webshop will be installed next to an existing Laravel website. The users are shared between the website and the webshop. They do not have to update their passwords that way.

For that reason I chose for the option: "Customers will be stored as users". I wouldn't mind switching to simple commerce's database driver but will I still be able to use the user model that uses the other database table if I go for that approach? Also that user has an addresses relation that is used in the front-end.

To clarify, my current User model (that I use in my Simple Commerce webshop) uses another database (on the same server). Like this:

protected $connection = 'mysql_other-database';

duncanmcclean commented 3 months ago

I wouldn't mind switching to simple commerce's database driver but will I still be able to use the user model that uses the other database table if I go for that approach?

Yes. After running the commands to switch orders to the database, you can switch back the customer driver to UserCustomerRepository and continue using your users as customers.

To clarify, my current User model (that I use in my Simple Commerce webshop) uses another database (on the same server). Like this:

protected $connection = 'mysql_other-database';

You might need to extend Simple Commerce's built-in Order model to change the connection but that's fairly easy to do.

de-raaf-media commented 3 months ago

Thanks Duncan. Only the user model uses another database. The Order model can remain the same I think.

duncanmcclean commented 3 months ago

Apart from #1035, does moving to use SC's database orders stuff work for you?

de-raaf-media commented 3 months ago

Yes, this seems to work.

duncanmcclean commented 3 months ago

Awesome! I'll close this issue then. Have a great rest of your week!

de-raaf-media commented 3 months ago

Thanks Duncan. You have a great week too!