• Resolved dingdang

    (@dingdang)


    In the following case:?
    – just one new field for the product is created (text) which is mandatory.?
    Will it be possible to have a direct add to cart URL and if yes what will be the additional parameter to pass??
    For example for the regular products it need just the product’s ID:?
    https://domain.com/?add-to-cart=55?
    In case there is a mandatory additional field:?
    a) is it possible at all with your plugin?
    b) what would be the variable name?
    c) is there also additional variables to pass in addition to b)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Maarten

    (@maartenbelmans)

    Hi there,

    If the text field is required, the direct add-to-cart URL will throw an error like “field X is required”. The only workaround to this is to make the text field not required.

    Thread Starter dingdang

    (@dingdang)

    I think you misunderstood me – I’d like to add the required field as well i.e. to add to cart a specific product with some predefined additional field using your plugin. Is this possible?

    Thread Starter dingdang

    (@dingdang)

    And to add here some of my tests:

    • if I send the add-to-cart url without the specific variable (I’ve got its name from the form) – yes as you suggested it will not be added to the cart
    • however if I do include the variable in the url with some value – the product is added to the cart but surprisingly WITHOUT the variable value’s taken into consideration – is this a bug?

    Plugin Author Maarten

    (@maartenbelmans)

    Your original question was related to the “add to cart” URL, no? Our plugin does not modify that URL. So if you have a required text field, the add to cart URL is still the same: https://domain.com/?add-to-cart=55?

    But our plugin does trigger add to cart validation so there will be an error because the system is trying to add a product to cart that is missing data (the required field).

    Does that make sense?

    Thread Starter dingdang

    (@dingdang)

    Done – just to close the case (I asked in my first question “is there also additional variables to pass in addition to b)” – after some more checking of the form you generate it happens that also the variable wapf_field_groups must be passed. In that case it works. So if anyone else needs this the format is the following:

    https://domain.com/?add-to-cart=SOMETHING&wapf%5Bfield_SOMETHING%5D=SOMETHING&wapf_field_groups=SOMETHING

    where SOMETHING must be replaced with appropriate values based on the specific product’s data.

    Thread Starter dingdang

    (@dingdang)

    And just to clarify again – the URL in my initial question was an example “before” and my question is how it should look “after” if I would like to add specific product with specific predefined custom field. In my previous reply I show how to do it and it is doable. Thanks!

    • This reply was modified 1 year, 10 months ago by dingdang.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘URL to add to cart’ is closed to new replies.