duncanmcclean / simple-commerce

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

Zero percent tax bug(s) #1038

Closed jamie-b5 closed 3 months ago

jamie-b5 commented 3 months ago

Description

Our client has added a zero percent (0%) tax category for pre-loved (second hand) items. This seems to produce 2 bugs.

Bug 1 - Trying to access array offset on value of type null

At point of adding product to basket (one using the zero tax rate).

image

Bug 2

(may or may not be related to the zero tax category).

In admin ->Products Index, customizing the columns to include Tax Category then refreshing the view displays the error

Call to a member function id() on null

image

and the products disappear!

Thanks in advance!

Jamie

Steps to reproduce

Bug 1: Zero tax product in basket

Create a tax rate with zero percent.

image

Assign this to a product

image

Add this product to your basket on the front end and we receive the error:

Trying to access array offset on value of type null

Bug 2: customizing columns with tax category (may be related?)

In the admin, go to products index and click customize columns.

Add in the tax category

image

Refresh the index view

image

Error is Call to a member function id() on null

If you remove the Tax Category from the customized columns the products are visible again.

Environment

This is my dev environment - same issue. I have a license for the production version FYI!

Environment
Application Name: Sound Organisation
Laravel Version: 10.22.0
PHP Version: 8.1.10
Composer Version: 2.4.1
Environment: local
Debug Mode: ENABLED
URL: sound_org.test
Maintenance Mode: OFF

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

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Simple Commerce
Currencies: GBP
Gateways: Stripe
Repository: Customer: DoubleThreeDigital\SimpleCommerce\Customers\EntryCustomerRepository
Repository: Order: DoubleThreeDigital\SimpleCommerce\Orders\EntryOrderRepository
Repository: Product: DoubleThreeDigital\SimpleCommerce\Products\EntryProductRepository
Shipping Methods: Free Overnight Shipping, Click and Collect
Tax Engine: DoubleThreeDigital\SimpleCommerce\Tax\Standard\TaxEngine

Statamic
Addons: 3
Antlers: runtime
Stache Watcher: Disabled
Static Caching: Disabled
Version: 4.21.0 PRO

Statamic Addons
doublethreedigital/simple-commerce: 5.6.2
jezzdk/statamic-google-maps: 1.2.2
rias/statamic-data-import: 1.3.0

duncanmcclean commented 3 months ago

Thanks for reporting this! I'll take a look when I have some time.

duncanmcclean commented 3 months ago

Hey 👋

I'm unable to reproduce this issue using the latest version of Simple Commerce, v6.0.11.

Are you able to try updating to see if that fixes the issue for you? Thanks.

jamie-b5 commented 3 months ago

Hi Duncan

Thanks for trying to reproduce the issue. I will upgrade to the latest version and see what happens.

Thanks

Jamie

duncanmcclean commented 3 months ago

I'm going to close this issue for the time being. Let me know if it doesn't fix the issue for you and I can re-open. Thanks!

jamie-b5 commented 3 months ago

Hi Duncan

I have upgraded to 5.9.2 and the error is still occurring. 5.9.2 is the highest version composer will allow me to update to.

If I specify the version 6.0.11 in the composer update command I receive the following error:

Class "DoubleThreeDigital\SimpleCommerce\Customers\EntryCustomerRepository" not found

I have updated core statamic to 4.55 (the latest as far as I am aware).

Any help greatly appreciated.

Thanks

Jamie

duncanmcclean commented 3 months ago

Did you follow the upgrade guide when updating? https://simple-commerce.duncanmcclean.com/upgrade-guides/v5-x-to-v6-0

jamie-b5 commented 3 months ago

Apologies, not spotted that.

I'll work through and update you.

Much appreciated.

jamie-b5 commented 3 months ago

Followed the steps in the guide but am still seeing an error.

`Class "DoubleThreeDigital\SimpleCommerce\Customers\EntryCustomerRepository" not found

at C:\laragon\www\servers\statamic-staging\sound_org\vendor\statamic\cms\src\Statamic.php:380
376▕ public static function repository($abstract, $concrete)
377▕ {
378▕ app()->singleton($abstract, $concrete);
379▕
➜ 380▕ foreach ($concrete::bindings() as $abstract => $concrete) {
381▕ app()->bind($abstract, $concrete);
382▕ }
383▕ }
384▕

1 C:\laragon\www\servers\statamic-staging\sound_org\vendor\duncanmcclean\simple-commerce\src\ServiceProvider.php:237
Statamic\Statamic::repository("DuncanMcClean\SimpleCommerce\Contracts\CustomerRepository", "DoubleThreeDigital\SimpleCommerce\Cu ntryCustomerRepository")

2 C:\laragon\www\servers\statamic-staging\sound_org\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:1038
DuncanMcClean\SimpleCommerce\ServiceProvider::DuncanMcClean\SimpleCommerce{closure}(Object(Illuminate\Foundation\Application)) `

Have also tried to re-run scripts with php please sc:run-update-scripts

duncanmcclean commented 3 months ago

In your simple-commerce.php config file, do a find & replace and change DoubleThreeDigital to DuncanMcClean.

jamie-b5 commented 3 months ago

I have done that but I'm still seeing errors

 Class "DoubleThreeDigital\SimpleCommerce\Shipping\BaseShippingMethod" not found

  at C:\laragon\www\servers\statamic-staging\sound_org\app\ShippingMethods\FreeOvernightShippingMethod.php:10

Do I need to manually find and replace all occurrences of DoubleThreeDigital with DuncanMcClean in the codebase?

Thanks

duncanmcclean commented 3 months ago

Do I need to manually find and replace all occurrences of DoubleThreeDigital with DuncanMcClean in the codebase?

Yes, you will need to.

jamie-b5 commented 3 months ago

Hi Duncan

Some progress. I have managed to upgrade to 6.0.11 but still seeing some issues.

image

The cart now reports a generic 500 error for any products added

image

This is reporting from the url http://sound_org.test/!/simple-commerce/cart-items is this a javascript function?

Also I am trying to run the update scripts as I noticed that the orders files needed to update their reference to the payment gateways etc but this seems to be taking a very long time to run (feels like it's hanging?)

image

Thanks again

duncanmcclean commented 3 months ago

The cart now reports a generic 500 error for any products added This is reporting from the url http://sound_org.test/!/simple-commerce/cart-items is this a javascript function?

Unfortunately, that's not much for me to go on. Are you able to open a new issue for this and include anything from your log file (in storage/logs)?

Also I am trying to run the update scripts as I noticed that the orders files needed to update their reference to the payment gateways etc but this seems to be taking a very long time to run (feels like it's hanging?)

If you have lots of orders, this is to be expected. It has to loop over all of them and update the data.

jamie-b5 commented 3 months ago

Thanks Duncan. I'll open a new issue and see if I can find more detail in the logs.