Skip to content
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 to cart removes custom field data in current cart #347

Closed
nfourtythree opened this issue May 18, 2018 · 5 comments
Closed

Adding to cart removes custom field data in current cart #347

nfourtythree opened this issue May 18, 2018 · 5 comments

Comments

@nfourtythree
Copy link
Contributor

Description

I have a custom field on the order/cart called quoteReference using the update cart form I can update and this persists as expected.

However, if you then add to cart (using a different update cart form) it wipes out the custom field data.

I have created a test twig template to demonstrate what is happening

{% set product = craft.products.one() %}
{% set cart = craft.commerce.carts.cart %}

<h3>Cart items: {{ cart.lineItems|length }}</h3>

{% if product %}

<h3>Update Cart Form - Add To Cart</h3>
<form method="POST">
  <fieldset>
    {{ csrfInput() }}
    <input type="hidden" name="action" value="commerce/cart/update-cart">

    {{ product.title }}
    <input type="text" name="purchasables[1][id]" value="{{ product.defaultVariant.id }}">
    <input type="text" name="purchasables[1][qty]" value="1">

    <input type="submit" name="submit" value="Add">
  </fieldset>
</form>
{% endif %}

<h3>Updated Cart Form - Custom Field (quote reference)</h3>
<form method="POST">
  <fieldset>
    {{ csrfInput() }}
    <input type="hidden" name="action" value="commerce/cart/update-cart">

    <input type="text" name="fields[quoteReference]" value="{{ cart.quoteReference }}">

    <input type="submit" name="submit" value="update">
  </fieldset>
</form>

I can't imagine that you would need to have all the custom field data in every update cart form?

Have detailed below how to reproduct the error with the demo template above.

Steps to reproduce

  1. Copy the twig template
  2. Click add in the first form
  3. Type something in the text box in the second form
  4. Click update
  5. Data persists in input with refreshes etc.
  6. Now click add in the top form again
  7. Data has disappeared from the input

Additional info

  • Craft version: Craft Pro 3.0.8
  • PHP version: Craft Pro 3.0.8
  • Database driver & version: MySQL 5.5.59
  • Plugins & versions: Commerce 2.0.0-beta.4.1
@nfourtythree
Copy link
Contributor Author

Any thoughts on this? I have a few custom fields in use on an order and every time you add to cart it just clears all that data.

Even to the point that if there is a custom field that is a radio button type it removed the default value.

@lukeholder
Copy link
Member

@nfourtythree sounds like a bug. Attempting to reproduce.

@nfourtythree
Copy link
Contributor Author

@lukeholder were you able to replicate this? Happy to screenshare if required or provide more data. This has unfortunately halted the project as the custom fields are needed through the checkout process.

Let me know if you need anything more or if there is anything I could take a look at.

Thanks!

@lukeholder
Copy link
Member

Confirmed it is a bug (compared to functionality in commerce 1). But sounds like we need to figure it out in craft core. Will give you an update soon.

@lukeholder
Copy link
Member

FYI Was a bug in commerce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants