- Add files
- Clear Cache
- Build Storefront
- Enjoy
Last active
March 5, 2021 13:25
-
-
Save develth/c0fb0d1a9f23beb231e767b7705e0c7d to your computer and use it in GitHub Desktop.
shopware6 variant select
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# extend buy-widget-form #} | |
{% sw_extends '@Storefront/storefront/page/product-detail/buy-widget-form.html.twig' %} | |
{% block page_product_detail_buy_quantity_container %} | |
<div class="col-12 col-sm-4 d-flex align-items-end"> | |
{% block page_product_detail_buy_quantity %} | |
<div class="form-group"> | |
<label for="lineItems[{{ product.id }}][quantity]">{{ 'detail.orderItemQuantity'|trans|sw_sanitize }}</label> | |
<select name="lineItems[{{ product.id }}][quantity]" | |
class="custom-select product-detail-quantity-select"> | |
{% for quantity in range(product.minPurchase, product.calculatedMaxPurchase, product.purchaseSteps) %} | |
<option value="{{ quantity }}"> | |
{{ quantity }}{% if product.packUnit %} {{ product.packUnit }}{% endif %} | |
</option> | |
{% endfor %} | |
</select> | |
</div> | |
{% endblock %} | |
</div> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add Plugin in /custom/plugins/THEMEPLUGIN/src/Resources/app/storefront/src/main.js | |
import VariantSwitchPlugin from './variant-switch/variant-switch.plugin'; | |
// if not set yet: const PluginManager = window.PluginManager; | |
PluginManager.override('VariantSwitch', VariantSwitchPlugin, '[data-variant-switch]'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create file in /custom/plugins/THEMEPLUGIN/src/Resources/app/storefront/src/variant-switch | |
import VariantSwitchBasePlugin from 'src/plugin/variant-switch/variant-switch.plugin'; | |
import Iterator from 'src/helper/iterator.helper'; | |
export default class VariantSwitchPlugin extends VariantSwitchBasePlugin { | |
/** | |
* returns the current selected | |
* variant options from the form | |
* | |
* @private | |
*/ | |
_getFormValue() { | |
const serialized = {}; | |
Iterator.iterate(this._radioFields, field => { | |
if (VariantSwitchPlugin._isFieldSerializable(field)) { | |
if (field.selected) { | |
serialized[field.parentNode.name] = field.value; | |
} | |
} | |
}); | |
return serialized; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment