I have a shopify hydrogen storefront. I am trying to use the official shopify bundles app to add bundles to cart on my storefront. Currently, the product adds to cart but is not visible in the cart. The user can checkout the bundle, but cannot view it in the cart. The issue seems to be at the CartForm.ACTIONS.addLines . I am passing in the correct information, but when i retrieve the cart lines, there is an empty array in place of the bundle.
Steps to Reproduce1. Create an ATC button:
function AddToCartButton({analytics, children, disabled, lines, onClick}) {
return (
{(fetcher) => (
<>
<button
type=“submit”
onClick={onClick}
disabled={disabled ?? fetcher.state !== ‘idle’}
className=“text-[#161616] bg-[#f5f5f0] md:text-[#f5f5f0] md:bg-[#f5f5f0] text-md py-2 px-7 rounded-[4px] w-60 md:w-[360px] h-[60px] md:h-14 cursor-pointer hover:bg-white/80 md:hover:bg-white/80 transition duration-300 ease-in-out”
{children}
</>
)}
);
}
-
Create /cart route with switch statement to allow for CartForm.ACTIONS.LinesAdd:
switch (action) {
case CartForm.ACTIONS.LinesAdd:
result = await cart.addLines(inputs.lines);break;
} -
Call this route with the AddToCartButton component, making a post request with inputs={{lines}}. Lines is an array with an object containing the correct merchandiseId and quantity. The input also contains an analytics string, but that is not related to this.
Expected Behavior
After this submission, the correct product should show up in the cart. When retrieving the cart lines, you should get back a lines object with a nodes array containing an id (id for the cartLine) and other information about the merchandise inside that line of the cart.
Actual Behavior
When I retrieve the cart lines, I get back an empty array for each line that a bundle was supposed to be in. When I go to checkout the cart, the bundle shows up in checkout. I cannot see the bundle in cart as there is no id for the cart line or any other information about the merchandise, just the empty array in it’s place. I cannot even allow the user to remove this empty cart item because there is no id to perform a cart.updateLines or cart.removeLines mutation on.