You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cart/add README example uses variant.id, which returns the Craft element ID instead of the Shopify variant ID (v7) #220
In v7, variant.id is the Craft element/row ID, not a Shopify identifier. Submitting this form sends e.g. id=7271 to the store, and Shopify responds:
Cart Error: Cannot find variant
Root cause
In v7 a variant is a craft\shopify\models\Variant (@since 7.0.0), where:
public ?int $id = null; // Craft row/element ID, e.g. 7271public ?string $shopifyId = null; // Shopify GID, e.g. gid://shopify/ProductVariant/55602221973830
So variant.id is never a Shopify identifier. The Shopify ID is on variant.shopifyId, but it's a GID (gid://shopify/ProductVariant/<numeric>), whereas the cart/add endpoint expects the bare numeric variant ID. The plugin itself strips this prefix elsewhere — see src/fieldlayoutelements/VariantsField.php:
This confirms shopifyId is a GID and there is no first-class numeric accessor on Variant.
Product vs. Variant inconsistency (related)
Products and variants are stored differently, and expose shopifyId differently:
Storage
Numeric ID exposed?
GID exposed?
Product
shopify_products table
✅ shopifyId (numeric)
✅ shopifyGid
Variant
shopify_data (type = ProductVariant)
❌ none
✅ shopifyId (the GID)
So product.shopifyId is a clean numeric, but variant.shopifyId is a GID — same property name, different shape — and variants have no numeric equivalent.
Suggested fixes (either/both)
Docs: update the README cart/add example to use the numeric portion of the variant's Shopify ID:
API (preferred): make Variant consistent with the Product element — expose a numeric shopifyId (and a shopifyGid for the GID) — so consumers don't have to string-split a GID for a documented, common workflow.
Thank you for reporting this. We have just released a new major version of the plugin, version 8.0. This takes a significant step to aligning all of the Shopify properties so there is complete consistency between ID and GID across the elements and models.
Please take care when upgrading to this version as a number of things have changed. Please consult the CHANGELOG and README to see if any of the changes affect your development/project.
Activity
linear-code commentedon Jun 16, 2026
PT-3147
nfourtythree commentedon Aug 25, 2026
Hi @rjgux
Thank you for reporting this. We have just released a new major version of the plugin, version
8.0. This takes a significant step to aligning all of the Shopify properties so there is complete consistency betweenIDandGIDacross the elements and models.Please take care when upgrading to this version as a number of things have changed. Please consult the
CHANGELOGandREADMEto see if any of the changes affect your development/project.Thanks!