Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module allows you to create links that automatically manipulate a user's shopping cart, enabling actions like emptying the cart, adding specific products with quantities, and redirecting to a designated page. This is useful for scenarios like directly sending customers to checkout with advertised products or facilitating punchout catalog purchases.

Commerce Cart Links lets you construct links that can manipulate a customer's shopping cart using query parameters. It supports emptying or deleting any existing cart and then adding one or more products to the cart, redirecting to an optional landing page after processing.

An example case for this module is checkout links through Google Merchant Center, allowing ads to send a shopper directly to the checkout form with a cart containing the advertised product. Another use case would be a punchout catalog purchase flow that directs the customer externally to Drupal Commerce to complete the transaction.

Building cart links

All cart links are handled by the /cart-links route. Cart contents are manipulated according to what follows in the URL:

  • 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.
  • Optionally, for each of the URL arguments, an entity type can be set to override the default entity type for the entities being purchased. For example, to add 2 of product variations 57 to the cart with the entity type commerce_product_variation, the URL would be /cart-links/57-2-commerce_product_variation.
  • Append the default_entity_type=# query parameter to set the default entity type for purchasable entities. If not set, commerce_product_variation will be used.
  • 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.
  • Append the store=# query parameter to force the use of a specific store when resolving or creating a new cart.
  • 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.
  • 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.
  • 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.
  • Append the coupon_code=# query parameter to automatically apply a specific coupon code when adding products to the cart.

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.

These parameters are designed to give you maximum control over how existing carts and / or new carts are treated prior to the add to cart operation. However, a multi-store site or a site that depends on users managing multiple carts may experience issues when a cart link bypasses the default store resolving process.

Activity

Total releases
4
First release
Apr 2025
Latest release
1 month ago
Releases (12 mo)
2
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.2.0 Stable May 27, 2026
1.1.0 Stable Sep 10, 2025
1.0.1 Stable May 16, 2025
1.0.0 Stable Apr 18, 2025