duncanmcclean / simple-commerce

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

Multi-site routes when using different domains #893

Closed Web10-Joris closed 1 year ago

Web10-Joris commented 1 year ago

Description

Hello, I'm planning to use different domains for each multi-site. Like example.com / example.de / example.nl. The cart page (and all other SC routes are not working then). Any idea how to fix this? Looks like the web routes are trying to add a prefix, but in the case of different domains there are now prefixes.

Site::all()->each(function (\Statamic\Sites\Site $site) {
    Route::prefix($site->url())->group(function () {
        Route::statamic('/cart', 'cart', ['title' => 'Your Cart']);

        Route::redirect('/checkout', '/checkout/information');
        Route::statamic('/checkout/information', 'checkout.information', ['title' => 'Checkout']);
        Route::statamic('/checkout/shipping', 'checkout.shipping', ['title' => 'Checkout']);
        Route::statamic('/checkout/payment', 'checkout.payment', ['title' => 'Checkout']);
        Route::statamic('/checkout/complete', 'checkout.complete', ['title' => 'Checkout']);

        Route::statamic('/checkout/offsite/mollie', 'checkout.offsite.mollie');
        Route::statamic('/checkout/offsite/paypal', 'checkout.offsite.paypal');
    });
});

Steps to reproduce

Try to make a multi-site with different domains as named above. Then access the /cart route. In my case I get a 404 not found error. The cart.antlers.html is inside the correct folder (resources/views)

Environment

Environment Application Name: XXXX Laravel Version: 10.15.0 PHP Version: 8.1.5 Composer Version: 2.5.5 Environment: local Debug Mode: ENABLED URL: localhost 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: EUR, EUR, EUR Gateways: Mollie Repository: Customer: DoubleThreeDigital\SimpleCommerce\Customers\EntryCustomerRepository Repository: Order: DoubleThreeDigital\SimpleCommerce\Orders\EntryOrderRepository Repository: Product: DoubleThreeDigital\SimpleCommerce\Products\EntryProductRepository Shipping Methods: Free Shipping Tax Engine: DoubleThreeDigital\SimpleCommerce\Tax\BasicTaxEngine

Statamic Addons: 8 Antlers: runtime Stache Watcher: Enabled Static Caching: Disabled Version: 4.11.0 PRO

Statamic Addons aerni/advanced-seo: 2.1.3 aryehraber/statamic-impersonator: 2.6.0 aryehraber/statamic-logbook: 3.1.0 doublethreedigital/simple-commerce: 5.3.0 rias/statamic-data-import: 1.3.0 statamic/collaboration: 0.7.2

duncanmcclean commented 1 year ago

If you're using different domains, maybe try replacing Route::prefix($site->url()) with Route::domain($site->url()) and see if that works?

I haven't used multi-site on different domains before.

Web10-Joris commented 1 year ago

Yes thanks for the very quick response! That works :)