Hello,
First, I would like to create this as a post rather than message, and feel like a dummy for not being able to find how to do that I thought i was past the user trust level where I can post.
I have been trying to set up Snipcart on a site, and am looking to let users checkmark which size item they can select:
https://cooperlovano.com/base/shop/shorts-white
In my individual product PHP:
<?php if ($variationavail > 1): ?>
<?php foreach ($page->sizeoptions()->split() as $sizeoption): ?>
<tr>
<td class="checkmark"><span class="table-cell"><input type="radio" id="productsize" name="productsize" value="<?= $sizeoption ?>"></span></td>
<td class=""><?= $sizeoption ?></td>
</tr>
<?php endforeach ?>
<?php endif ?>
The checkmarks are displaying appropriately, and I set it up to save the selected size as a PHP cookie. This successfully worked and displayed the selected size on the next page:
(Here is the Snipcart button that created to display the selection):
<button class="cta snipcart-add-item"
data-item-id="<?= $page->slug() ?>"
data-item-price="<?= $page->price()->html() ?>"
data-item-url="<?= $page->url() ?>"
data-item-image="<?= $page->image()->resize(150)->url() ?>"
data-item-name="<?= $page->title()->html() ?>"
data-item-custom1-name="Size"
data-item-custom1-options="<?php echo $_COOKIE['sizechoice'] ?>">
Add to cart
</button>
I am running into problems when trying to reset the cookie value, so the user can go back and select a different size. (The originally selected one stays, it only adds more of that size)
This is quiiite new to me, and I have been running myself into walls.
Is there an alternative approach you would suggest to be able to allow the user to select the size of their item before selecting ‘Add to Cart’?