Skip to content

Commit

Permalink
Pass Alpine instance to createStore and createData (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell authored Dec 12, 2024
1 parent 7fbd3b3 commit bdf55d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/content/en/frontend/storefront-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ import Alpine from 'alpinejs';

window.Alpine = Alpine;

createStore();
createData();
createStore(Alpine);
createData(Alpine);

Alpine.start();
```
Expand All @@ -152,7 +152,7 @@ To use it:

```antlers
{{ $variants = {shopify:variants} }}
<div x-data='statamic.shopify.product({{ options | to_json }}, {{ variants | to_json }})'>
<div x-data='shopifyProduct({{ options | to_json }}, {{ variants | to_json }})'>
<form @submit.prevent="handleSubmit($event.target)">
<input type="hidden" name="product_id" id="ss-product-id" value="{{ product_id }}" />
Expand Down
5 changes: 2 additions & 3 deletions resources/js/shopify/alpine.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { addLines, getOrCreateCart, removeLine, setCartAttributes, setCartNote, updateLineQuantity } from './cart';
import Alpine from 'alpinejs';

const createStore = () => {
const createStore = (Alpine) => {
Alpine.store('statamic.shopify.cart', {
cartId: null,
checkoutUrl: '',
Expand Down Expand Up @@ -76,7 +75,7 @@ const createStore = () => {
});
}

const createData = () => {
const createData = (Alpine) => {
Alpine.data('shopifyProduct', (options, variants) => ({
added: false,
customAttributes: {},
Expand Down

0 comments on commit bdf55d3

Please sign in to comment.