const appendByAttr = (title, subtitle) => jQuery(`a[title="${title}"] ~ .ammenu-submenu-container .ammenu-item.-child.-col-4 a[title="${subtitle}"] ~ ul li:last-child`)
.append($(`a[title="${title}"] ~ .ammenu-submenu-container .ammenu-item__extra`));
appendByAttr('Title 1', 'Subtitle 1');
appendByAttr('Title 2', 'Subtitle 2');
appendByAttr('Title 3', 'Subtitle 3');
var handlerOne = function(e) {
alert('This is a first function');
};
var handlerTwo = function(e) {
alert('This is a second function');
};
$('.first').click(function(e) {
handlerOne(e);
})
$('.second').click(function() {
handlerOne(e);
handlerTwo(e);
})
jQuery("select#qty").append("<option value=''>Выберите кол-во товаров...</option>")
<script> require(['jquery', 'Magento_Catalog/js/price-utils'], function ($, priceUtils) {
'use strict';
var tierPrices = <?php echo json_encode($allTiers) ?>;
var createDropdown = function () {
jQuery("select#qty").append("<option value=''>Выберите кол-во товаров...</option>")
for (var i = 0; i < tierPrices.length; i++) {
var obj = tierPrices[i];
jQuery("select#qty").append("<option value='" + Number(obj.price_qty) + "'>Buy " + Number(obj.price_qty) + " For " + priceUtils.formatPrice(obj.price) + " each</option>")
}
};
var getPrice = function (qty) {
qty = Number(qty);
var i = tierPrices.length;
while (i--) {
if (qty >= tierPrices[i]['price_qty']) {
return tierPrices[i]['price'];
}
}
return null;
};
var updatePrice = function (price) {
var newPrice = priceUtils.formatPrice(price);
jQuery('.price-final_price .price').html(newPrice);
};
var updatePriceHtml = function (amount) {
var price = getPrice(amount);
if (price !== null) {
updatePrice(price);
}
};
jQuery('select#qty').change(function () {
if (tierPrices.length > 0) {
updatePriceHtml(this.value);
}
});
setTimeout(function () {
if (tierPrices.length > 0) {
createDropdown();
updatePriceHtml(jQuery('select#qty').val());
}
}, 700);
});
</script>
document.body.querySelectorAll(".menu-item.parent").forEach(menu => {
const URL = menu.querySelector(".menu-link").href;
const clildMenu = menu.querySelector(".menu-item.child");
clildMenu.insertAdjacentHTML(
"beforeend",
`<li class='menu-wrapper'><a class='more' href='${URL}'><span class='title'>show all »</span></a></li>`
);
});
public function getTreeHtml(Node $node, $level = 1)
.......
if ($node->hasChildren()) {
........
foreach () {
...............
$html .= '</li>';
$counter++;
}
if ($this->escapeUrl($node->getUrl())) {
$html .= sprintf(
'<li class="ammenu-wrapper" %s><a href="%s" title="Show all: %s" class="ammenu-link -level%s">
<span class="ammenu-wrapper">Show all: %s</span>
</a></li>',
$parentDataAttr,
$this->escapeUrl($node->getUrl()),
$this->escapeHtml($node->getName()),
$level,
$this->escapeHtml($node->getName())
);
}
}
}
$('.menu-item > .submenu').toggleClass('show-submenu');
$(this).find('.submenu').toggleClass('show-submenu');