duncanmcclean / simple-commerce

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

Shipping method not found after upgrade to v6 #1009

Closed sstottelaar closed 4 months ago

sstottelaar commented 5 months ago

Description

I upgraded to v6 and I ran into an issue that no shipping methods are found. I took all the steps as described in the upgrade guide. Even if I try with the built-in free shipping method I get this error:

image

My code that defines the shipping methods:

'sites' => [
    'default' => [
        'currency' => 'EUR',
            'shipping' => [
                'default_method' => \DuncanMcClean\SimpleCommerce\Shipping\FreeShipping::class,

                'methods' => [
                    \DuncanMcClean\SimpleCommerce\Shipping\FreeShipping::class => [],
    ],
],

Is there anything missing from the docs or my code that might be causing this issue? I tried clearing cache, dump-autoload etc.

Any help is appreciated!

Steps to reproduce

  1. Upgrade from v5 to v6
  2. Create a custom shipping method with php please make:shipping-method YourNewShippingMethod
  3. Add a product to cart
  4. Get error

Environment

Environment Application Name: App Laravel Version: 10.38.1 PHP Version: 8.2.15 Composer Version: 2.5.5 Environment: local Debug Mode: ENABLED URL: erw5eowfwv.sharedwithexpose.com Maintenance Mode: OFF

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

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

Simple Commerce Currencies: EUR Gateways: Mollie Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EntryCustomerRepository Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository Shipping Methods: Free Shipping Tax Engine: DuncanMcClean\SimpleCommerce\Tax\Standard\TaxEngine

Statamic Addons: 4 Antlers: runtime Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 4.48.0 PRO

Statamic Addons aerni/font-awesome: 2.0.0 duncanmcclean/simple-commerce: 6.0.5 mattrothenberg/statamic-mapbox-address: 0.7.4 withcandour/aardvark-seo: 3.0.1

duncanmcclean commented 5 months ago

Can you try changing default_method to free_shipping instead?

sstottelaar commented 5 months ago

This did the trick, thanks a lot. Did I miss this from the upgrade guide? My bad.

duncanmcclean commented 5 months ago

No, you didn't miss it. I missed adding it to the upgrade guide.

sstottelaar commented 4 months ago

Hi Duncan, this issue remains. I noticed that when implementing this code:

'sites' => [
        'default' => [
            'currency' => 'EUR',

            'shipping' => [
                // 'mailbox_shipping' => \App\ShippingMethods\MailboxShipping::class,
                'default_method' => \App\ShippingMethods\MailboxShipping::class,

                'methods' => [
                    App\ShippingMethods\MailboxShipping::class => [],
                    App\ShippingMethods\ParcelShipping::class => [],
                ],
            ],
        ],
    ],

I get the following error:

image

So earlier in the issue, I fixed the wrong thing, which led to not defaulting to any shipping method. Now when I try both the class name and the handle, it doesn't work.

Anything I'm missing here?

duncanmcclean commented 4 months ago

The default_method now needs to be the handle of the shipping method, not the FCQN (the fully qualified class name).

So, something like this should work:

'default_method' => 'mailbox_shipping',

If there's something else that's not working when the default shipping method is a handle, please open another issue.