Hi,
This is a view override issue, not a core bug. Two things need to be adjusted in your customization:
1. Multiple prices showing after variant selection: Your code loops over $this->element->prices which, after a variant is selected, contains the prices of all variants. You need to check if a variant is selected and use its prices instead. For example:
$prices = $this->element->prices;
if(!empty($this->element->main)) {
$prices = $this->element->main->prices;
}
Or better, listen to the variant selection and rebuild the buttons from the selected variant's prices via JavaScript.
2. Quantity buttons stop working after variant change: When a variant is selected, HikaShop refreshes parts of the page via AJAX, which replaces the DOM elements your event listeners were attached to. You need to re-initialize your click handlers after each variant change by listening to HikaShop's content change event:
window.Oby.registerAjax(['hkContentChanged'], function() {
// Re-bind your bulk-option click handlers here
document.querySelectorAll('.bulk-option').forEach(function(option) {
option.addEventListener('click', function() {
// ... your existing click handler code
});
});
});
This event fires each time a variant is selected and the page content is updated.