Basically the title.
I update the checkout line item with applyCartLinesChange() function and expect the line item (returned by the useCartLineTarget() hook) to be updated. And it works fine when I update product variant (so called merchandiseId). But when I update sellingPlanId alone, the line item is not updated, and therefore the app is not re-rendered.
Example:
import {
Banner,
reactExtension,
useCartLineTarget,
useApplyCartLinesChange,
Button,
} from '@shopify/ui-extensions-react/checkout';
export default reactExtension(
'purchase.checkout.cart-line-item.render-after',
() => <Extension />,
);
function Extension() {
const lineItem = useCartLineTarget();
const applyCartLinesChange = useApplyCartLinesChange();
const handleSetSellingPlan = () => {
applyCartLinesChange({
type: 'updateCartLine',
id: lineItem.id,
sellingPlanId: 'gid://shopify/SellingPlan/SomeNumbersHere',
});
};
return (
<>
<Banner>
Selling plan id: {lineItem.merchandise.sellingPlan?.id ?? 'empty'}
</Banner>
<Button onPress={ handleSetSellingPlan }>Set Selling Plan</Button>
</>
);
}
In this app the banner shows current selling plan id of the line item. The button sets the selling plan, and it is set successfully on click (I literally see the price change), but the banner still shows empty selling plan.
This means useCartLineTarget() hook doesn’t work as expected (lineItem variable is not updated).
Is there a workaround? Thanks


