3

I have a Magento shop with some configurable products. Those products have 3 configurable attributes from an attribute set and 1 custom option that is set on the configurable product itself (so not from the attribute set).

What I want to do is set the attributes and custom options via an url. So when we send that url to a customer via mail, and he clicks on it, it is already configured (but he can still change it via the dropdowns if he wants).

I know you can do this by adding values to the url. For example:

http://www.shop.com/cat/product.html#132=4&140=16&139=15&3=21

But this only works for the 3 configurable product attributes, NOT for the custom option. Is this something that can be done (but am I using the wrong syntax), or is this something that needs modification of the code?

Thanks!

1 Answer 1

2

There is not a way to select a custom option based off a URL parameter. The custom options are not rendered the same as configurable attributes.

This is the code that defaults the attribute values

var separatorIndex = window.location.href.indexOf('#');
    if (separatorIndex != -1) {
        var paramsStr = window.location.href.substr(separatorIndex+1);
        var urlValues = paramsStr.toQueryParams();
        if (!this.values) {
            this.values = {};
        }
        for (var i in urlValues) {
            this.values[i] = urlValues[i];
        }
    }

    this.configureForValues();

You could write something custom to do exactly what you are looking for using jQuery.param().

http://api.jquery.com/jquery.param/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.