-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding customAttributes to cart and lineItems #746
base: master
Are you sure you want to change the base?
Conversation
a55f4d3
to
cdf78c7
Compare
@mahlingam would you be able to compile the js file with this change and make it public somewhere? I'm very interested, unfortunately this repo doesn't seem to compile under macOS 11. |
I managed to compile it by shedding some dependencies and using |
@gmalette hey, long time :) any chance you have a fork with a compilable version? |
@jnormore JASON! LONG TIME! Sorry I hadn't seen your message, wasn't checking notifications. I do have one, and though I imagine it's some months too late, here it is https://github.com/gmalette/buy-button-js/tree/line-item-properties |
any idea why it hasn't been merged yet? |
Can we get this merged please? |
Sorry to ask but where does |
same as productId and variantId, it is the value of the data-line-item-attributes attribute, the name is mangled according to https://html.spec.whatwg.org/multipage/dom.html#dom-dataset and https://api.jquery.com/data/ |
Could I possible have some help with this? I'm assuming this still isn't possible with the master version? I've currently added "customAttributes: [ { "key": "_someHiddenKey", "value": "someHiddenValue"}, { "key": "someKey", "value": "someValue"} ]" directly to ui.createComponent('product' just to get some custom attributes coming through on the order. Nothing yet, though. Also, after building with yarn, I wrapped the script in the ShopifyBuy function, so it works in the same way as the original Shopify buy button, rather than as a module. Is there any reason to not do this? It seems to work fine (other than the custom attributes). Any help on configuring this correctly would be much appreciated :) Tom |
I started afresh and this is now working fine with some dummy data added directly to customAttributes in ui.createComponent. My only question now is how to pass a custom attribute from an input, either on the product or product modal, to the line item when added to cart? Would you mind pointing me in the right direction, here? |
Glad you got it working. I use the buy button integrated into a custom frontend:
and a script fragment embeded in the product template:
|
events: {
|
thank you @mahlingam I was looking to do the same thing, and your PR was very helpful. For others looking for this, I have forked and compiled a library with support for custom attributes so others can learn how to do this. |
is there anything blocking this pull? the hard work has been done and is in use by many people. it would be great to have this merged and "properly" supported |
+1 the merge of this. Very strange that we can't retrieve the checkout id from the UI mode, would make things way easier. |
see issue #598