Commerce Product URLs
Module providing unique URLs for particular product variations referenced by one product display. (A temporary solution for issue #1082596: Implement unique URLs for particular products on product displays.)
- For each product it provides id parameter, for example:http://www.mycommercesite.com/node/1?id=1http://www.mycommercesite.com/node/1?id=2
as well as sku parameter, for example:http://www.mycommercesite.com/node/1?sku=pr1http://www.mycommercesite.com/node/1?sku=pr2
- For product types with extra fields enabled to function as an attribute field for Add to Cart forms, it provides option to use values of those fields to select specific product variation.
For example, if a product type has a Term reference field with machine name field_color, and product has a term tid = 2, name = Red selected, then such product variation could be displayed using either:http://www.mycommercesite.com/node/1?color=Red (note this is case-sensitive), or:http://www.mycommercesite.com/node/1?color=2
You can find all the fields available on specific product types in Admin / Store / Products / Product types / <product_type> / Manage fields, or, in case of Kickstart 2, in Admin / Products / Variation types / <variation_type> / Manage fields.
Note that to use field value filter in the URL, you need to remove "field_" string from field's machine name - and thus, based on example of Tops product variation in Kickstart 2, you can use
?color=URL param for Color field, or
?top_size=param for Size field.
- Updates product links in the shopping cart pointing them to correct product variations instead of generic product display.
- Redirects back to correct product variation instead of generic product display after adding a product to the cart.
- Updates page URL adding current product's id to the query string after changing the value of any of the Add to Cart form attribute fields. Note that this part of code is experimental (and as such disabled by default, has to be enabled manually on module settings page), as it uses HTML5's
history.pushState(), which is not going to work in all browsers. For such older browsers a fallback to location.search updating has been added in the most recent dev version.
The module has been covered by Josh Miller in the Commerce Module Tuesday series.
- Use release 7.x-1.0 for Drupal Commerce versions 1.5 and below.
- Use release 7.x-1.1 and later for Drupal Commerce versions 1.6 and above.