1

I an deleting items from spree cart using the following spree api url

/api/orders/#{current_order.number}/line_items/#{line_iem.id}?line_item[variant_id]=#{line_item.variant.id}&line_item[quantity]=0&token=MyToken

the token used here is of a single user. I want to implement this in generic way so that it can be used for both guest and registered user.. is it possible?

any help would be highly appreciated

Regards

Aitizazk
  • 332
  • 1
  • 4
  • 16

1 Answers1

0

Whenever you create an order using the Spree API, you get an order_token in the response. From the Spree API Guide:

The order_token parameter will work for authorizing any action for an order within Spree’s API.

So instead of appending &token=... you should append &order_token=...

It will work for both registered users as well as guests.

Sanad Liaquat
  • 182
  • 1
  • 8
  • but i am using this link in ajax in my spree web app. how can I get the value of order token ? – Aitizazk Aug 30 '15 at 15:49
  • Ok. You did not mention that in your question. Can you please show some more context/code around the url in your question. Specifically, I am interested in knowing where are you getting the "current_order" from. – Sanad Liaquat Aug 30 '15 at 17:05
  • Actually i was implementing cart side bar from which user can update or delete items directly. i am simply using current_order.guest_token – Aitizazk Sep 02 '15 at 14:04