Skip to content

Get url to continue cart session #1032

Closed Answered by duncanmcclean
Web10-Joris asked this question in Help
Discussion options

You must be logged in to vote

Simple Commerce doesn't have anything built-in for this. However, you could achieve this with a custom route.

Assuming you're using the cookie cart driver, you could do something like this:

// routes/web.php

use DuncanMcClean\SimpleCommerce\Facades\Order;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\Blink;
use Statamic\Facades\Site;

Route::get('/back-to-cart/{orderId}', function (Request $request, $orderId) {
    $order = Order::find($orderId);

    if (! $order) {
        return redirect('/');
    }

    $key = config('simple-commerce.cart.key', 'simple-commerce-cart');

    $site = $this->guessSiteFromRe…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Web10-Joris
Comment options

You must be logged in to vote
1 reply
@duncanmcclean
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants