jeffharrell / minicart

The minicart is a great way to improve your PayPal shopping cart integration.
MIT License
500 stars 209 forks source link

How to add custom data e.g return url? #233

Closed garygreen closed 10 years ago

garygreen commented 10 years ago

Changing the default settings for the actual cart isn't well documented -- How could this be achieved? I would also like to add custom field to send to Paypal.

jeffharrell commented 10 years ago

Adding additional variables to the minicart is the same as adding them to a PayPal button. Are you not seeing custom work?

garygreen commented 10 years ago

@jeffharrell Ohh, maybe I'm just a bit confused how the minicart decides what 'custom' data to finally send when clicking checkout. Would it send the last 'custom' field added? (for the last buy button clicked on)

jeffharrell commented 10 years ago

Yes, it should work and be passed back to you after PayPal returns the cart to you. That said, I don't believe I've tested that actually works, so if you find it's not the case let me know.

I should call out that I currently have it specified as a "cart" property, i.e. https://github.com/jeffharrell/minicart/blob/master/src/constants.js#L8 which means that only one custom attribute applies per cart. I'm actually not sure if it should be per cart or per product... If it doesn't work it may need to be the opposite and I can change it.

garygreen commented 10 years ago

Thanks so much for your help. I know the plugin is really to be used with the generated Paypal buy it now buttons but so there are always duplicated fields which (imo) really should ideally be a part of the cart's setting as a whole -- for instance when sending to paypal I think the return_url should only be sent once, not per item. Same for the custom field -- it's per transaction not per item. It's the confusion between what the cart actually chooses to send when the checkout button is pressed as some fields should be per the whole cart not per item. If that makes sense?

jeffharrell commented 10 years ago

Agreed, but since this is plugging into PayPal's button API it's more confusing to change their documented behavior and re-document it solely for the minicart than it is to just say that cart-wide settings inside of a button will take precedence when adding a new product.

For the moment, this will just need to remain a caveat of using the cart.