Replies: 1 comment
-
Even though you're providing the CSRF token in the HTTP request, there's probably something else session-related you're missing in the request which is causing it not to work. Instead of making an HTTP request, it might be easier to add the line item manually, using Simple Commerce's PHP APIs: use DuncanMcClean\SimpleCommerce\Orders\Cart\Drivers\CartDriver;
class YourComponent extends Component
{
use CartDriver;
public function doSomething()
{
$this->getCart()->addLineItem([
'product' => 'product-id',
'variant' => 'variant-id',
'quantity' => 1,
'total' => 1500,
])->save();
}
} ^ I haven't tested this code snippet, but I believe it should work. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm using Livewire and want to add item to cart. But I get the message "CSRF token mismatch".
This is the code for making the HTTP request:
The csrf_token() and the {{ csrf_token() }} (in my blade) are the same. Does someone have any idea how I can fix this?
Or is there maybe another option to call a method inside PHP to update the card?
Beta Was this translation helpful? Give feedback.
All reactions