duncanmcclean / simple-commerce

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

Sometimes an empty order is added #1062

Closed de-raaf-media closed 4 weeks ago

de-raaf-media commented 2 months ago

Description

As described in #1060. Seems to have something to do with the debugbar. If you need more info let me know.

Steps to reproduce

I noticed this happened sometimes when I added a product to the card. But not all the time? After setting the debugbar to false in my config everything seems to work.

Environment

Environment Application Name: De Raaf Webshop Laravel Version: 10.48.8 PHP Version: 8.2.16 Composer Version: 2.7.1 Environment: local Debug Mode: ENABLED URL: webshop.deraaf.test Maintenance Mode: OFF

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED

Drivers Broadcasting: log Cache: statamic Database: mysql Logs: daily Mail: smtp Queue: sync Session: file

Simple Commerce Currencies: EUR Gateways: Dummy Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EloquentCustomerRepository Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EloquentOrderRepository Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository Shipping Methods: Free Shipping Tax Engine: DuncanMcClean\SimpleCommerce\Tax\BasicTaxEngine

Livewire Livewire: v3.4.10

Statamic Addons: 5 Antlers: runtime Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 4.57.0 PRO

Statamic Addons duncanmcclean/simple-commerce: 6.2.0 jonassiewertsen/statamic-livewire: 3.2.0 reachweb/statamic-livewire-filters: 1.7.0 statamic-rad-pack/runway: 6.6.4 statamic/eloquent-driver: 3.4.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 2 months ago

Hmm, I can't seem to reproduce this myself. Let me know if you're able to figure out what's causing it and I can investigate.

de-raaf-media commented 2 months ago

Hm ... could't tell. I installed the Livewire add-on. That's the only thing I could think of.

sstottelaar commented 1 month ago

@de-raaf-media I've got the same issue and wondered if it was just me. After a couple of minutes when I work locally, my git changes look like this:

image

Is this the same issue as you experienced?

de-raaf-media commented 1 month ago

@sstottelaar The only difference is that I store orders in the database. From your screenshot I cannot tell if they are the same. Are those orders empty? Like my example in #1060?

Are you using the Debug Bar as well? Because If I disable that the issue does no longer occur.

sstottelaar commented 1 month ago

@de-raaf-media yeah, the orders were all empty. I don't have the issues anymore after fixing a small issue in my template. In the header I checked if the cart had items, which created a cart everytime the code was executed. I found this solution in another issue, can't recall which one exactly. The code looked something like this:

{{ sc:cart }}
  {{ if items > 0 }}
    <div class="absolute top-[8px] right-0 flex items-center justify-center w-4 h-4 text-white rounded-full aspect-square bg-pumpkin-500">
      <span class="text-xs/none">
        {{ items | count }}
      </span>
    </div>
  {{ /if }}
{{/cs:cart}}

And i changed it into this:

{{ if sc:cart:count > 0 }}
  <div class="absolute top-[8px] right-0 flex items-center justify-center w-4 h-4 text-white rounded-full aspect-square bg-pumpkin-500">
    <span class="text-xs/none">
      {{ items | count }}
    </span>
  </div>
{{ /if }}

Maybe you have something similar in your code?

mwagena commented 1 month ago

I have had the same issue with the debugbar enabled, I have started my project based on the SC starter kit

de-raaf-media commented 4 weeks ago

Thanks @duncanmcclean.