Closed nelson-maze closed 6 months ago
Hi @nelson-maze! Please report bugs with Function APIs on Community. Issues on these OSS repos should be directly related to the code within.
Hi Nick - thanks, appreciate the corrected location for this. Issue is opened there, linking here for posterity: https://community.shopify.com/c/shopify-functions/carttransform-merge-operations-seem-unstable-with-quantities/td-p/2544569
On Tue, Apr 23, 2024 at 11:55 AM Nick Wesselman @.***> wrote:
Hi @nelson-maze https://github.com/nelson-maze! Please report bugs with Function APIs on Community https://community.shopify.com/c/shopify-functions/bd-p/functions. Issues on these OSS repos should be directly related to the code within.
— Reply to this email directly, view it on GitHub https://github.com/Shopify/function-examples/issues/489#issuecomment-2073199343, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY6ANPJT7KC2QG5ES5RJ5CLY62VDNAVCNFSM6AAAAABGVPGPACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZTGE4TSMZUGM . You are receiving this because you were mentioned.Message ID: @.***>
Which template or example
CartTransform - Merge Operation
Describe the bug
Line Item issues begin to occur with any multiple of a CartTransform Merge "bundle" being added to the cart (either by incrementing via form submission on the cart page or via cart AJAX API). Adding any other line items and bundles only exacerbates the issue.
Partner app dashboard logs indicate that function invocations are occurring where the cart line item inputs are being modified outside of the function's execution, along with potentially extra function invocations being made along the way (accelerating the duplication issues).
Steps to reproduce
Assumptions
Steps
Add 1 of each of the component products to the cart to manually create the bundle in-cart.
(2/3 bundle products added to cart)
(3/3 bundle products added to cart)
Note that this first invocation/interaction properly results in a single bundle being rendered in cart. This is also evident in the partner logs. (3 products input results in 1 Merge Operation with the 3 required component line items in the correct quantities). FirstBundleInput.json: FirstBundleInput.json FirstBundleOutput.json: FirstBundleOutput.json
From the cart page, increment the bundle to 2 via the "+" button.
Proceed to checkout via the checkout button on the cart page with the current cart of 2 bundles and 2 "empty" bundles.
These function invocations with modified inputs result in the cart now being completely different from even the original "2" line items (Cart AJAX API line items JSON found here CartResponse_FirstDuplicationResponse.json):
Navigate back to the cart page, and attempt to "correct" the cart by deleting a line item (any of them)
This only results in a continuation of the duplication issues, which after 2 attempts finally results in such a large quantity of line items that the runtime instruction count limit is exceeded, finally resulting in all bundles being broken up, as shown in the cart.
The Function input/output logs of this are below: DeleteAttemptInput: DeleteAttemptInput.json DeleteAttemptOutput: DeleteAttemptOutput.json
Expected behavior
Adding/deleting multiple mergeOperation bundles to the cart should behave the same as adding/deleting multiple "normal" variants to the cart (via form submission or cart AJAX API).
Incrementing and decrementing the quantity of mergeOperation bundles should behave the same as with "normal" variants and should increment/decrement the underlying component variants in the cart properly.
Line items should not duplicate without user interaction and the pricing should be consistent with multiple bundles added to the cart.
Merge Operations should not result in bug/artifact line items being added to the cart response JSON.
Environment
Additional context
This is occurring in multiple Shopify Plus environments.