Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When the option has a "-" (dash) for the add to cart url the option is truncated when is reaches the first dash within the shopping cart.
For the example url below the option value assigned in the shopping cart is 25 instead of what it should be which is 25-14-27-400-004
https://mydomain/cart/add/p110_a2o25-14-27-400-004
Comment | File | Size | Author |
---|---|---|---|
#5 | 960630-cart-links-escape-dashes.patch | 1.28 KB | longwave |
Comments
Comment #1
TR CreditAttribution: TR commentedOption ID is an internal Ubercart identifier, which is why I can say positively that option ID never has a dash.
Comment #2
mitchelljj CreditAttribution: mitchelljj commentedYou misunderstand using the example below
https://mydomain/cart/add/p110_a2o25-14-27-400-004
a2 represents the attribute name that is associated to the aid (attribute id) of 2 and
o25-14-27-400-004 represents the value that is assigned the attribute in the case it will be 25-14-27-400-004, but when sending this to the shopping cart via the add to cart url listed above only 25 is assigned to the attribute instead of 25-14-27-400-004.
Also having this same 25-14-27-400-004 value assigned to the attribute within the ubercart product page and then clicking on the add to cart button the entire value of the attribute (25-14-27-400-004) is assigned within the shopping cart unlike when clicking the add to cart link which only assigns 25 (which is the string before the first dash) to the attribute within the shopping cart.
Comment #3
TR CreditAttribution: TR commentedIt's easy to misunderstand when you don't explain your problem well. I'm changing the title to what I *think* you mean.
Comment #4
TR CreditAttribution: TR commentedThis should be fixed in 7.x-3.x first, then backported if necessary.
Comment #5
longwaveDashes are special characters in cart links, so the only way around this is to escape them. This patch supports escaping dashes with backslashes, so the example above becomes https://mydomain/cart/add/p110_a2o25\-14\-27\-400\-004
Comment #6
longwaveComment #7
longwaveI think this is such a minor problem that it can be ignored; there can't be many cases where attribute textfield options must contain dashes and can't use underscores instead. If this really is a problem for someone, feel free to revive this issue.
Comment #8
coderama CreditAttribution: coderama commentedThis is a serious problem for me. I have a specific use case where I think cart links should be able to support "-". My product is a "domain name". A domain name has attributes: ID protection enabled, domain name, domain extension etc.
The domain name attribute has to be text for this to work. And it must support numbers, hyphens and letters. So for this specific scenario, I can't create add to cart links.