Add a custom route /cart-links and related functionality

Created on 28 November 2023, 7 months ago
Updated 29 November 2023, 7 months ago

Cart contents are manipulated according to what follows in the URL:

  1. At least one URL argument including a product variation ID and quantity to be added to the cart separated by a hyphen. For example, to add 2 of product variation 57 to the cart, the URL would be /cart-links/57-2. To add additional products to the cart, use multiple such URL arguments, e.g. /cart-links/57-2/384-1.
  2. Append the destination=redirect/url query parameter to redirect the customer to a specific URL after the cart link has been processed similar to the query parameter behavior on form submission. If this parameter is omitted, the customer will either be redirected to the shopping cart form.
  3. Append the store=# query parameter to force the use of a specific store when resolving or creating a new cart.
  4. Append the existing query parameter with the value of new to force the creation of a new cart for this link without affecting any other carts the user may already have.
  5. Append the existing query parameter with the value of empty to empty a customer's existing cart (if one exists) before adding any the new product(s) to it.
  6. Append the existing query parameter with the value of delete to delete a customer's existing cart(s) before processing the cart link, meaning a new cart will always be created.

If the existing query parameter is not set in the link, Commerce Cart Links will simply add the relevant product(s) to whatever cart is resolved for the user.

πŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine marchuk.vitaliy Rivne, UA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024