generated from boboko/starter
cart drawer and general structure
This commit is contained in:
@@ -38,6 +38,13 @@ export default class extends Controller {
|
||||
this.imageTarget.src = variant.image
|
||||
}
|
||||
|
||||
// Keep the checkout module's add-to-cart form pointed at the chosen
|
||||
// variant. [data-bbk-purchasable-input] is that module's documented
|
||||
// hook (see resources/views/checkout/components/add-to-cart.blade.php);
|
||||
// this is the one place the two touch.
|
||||
const purchasableInput = this.element.querySelector('[data-bbk-purchasable-input]')
|
||||
if (purchasableInput) purchasableInput.value = id
|
||||
|
||||
this.swatchTargets.forEach(swatch => {
|
||||
const isSelected = parseInt(swatch.dataset.variantId) === id
|
||||
swatch.classList.toggle('is-selected', isSelected)
|
||||
|
||||
Reference in New Issue
Block a user