Answer the question
In order to leave comments, you need to log in
How to display a button on the product list page?
Please tell me, there is an Art WooCommerce Order One Click plugin , I really like it, but it does not display the quick buy button in the product list.
How to do it, I try something like add_filter('woocommerce_after_shop_loop_item','awooc_order_one_click', 7 ); , nifiga is not obtained.
I will be grateful for help.
Thank you.
Answer the question
In order to leave comments, you need to log in
Adding to Theme Functions
// вывод кнопок плагин Art WooCommerce Order One Click + выбор количества при добавлении простых товаров в корзину с поддержкой AJAX на страницах категорий товаров
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
function custom_woo_loop_add_to_cart_link($button, $product) {
if (!in_array($product->product_type, array('variable', 'grouped', 'external'))) {
if ($product->is_purchasable()) {
ob_start();
woocommerce_simple_add_to_cart();
$button = ob_get_clean();
$replacement = sprintf('data-product_id="%d" data-quantity="1" $1 ajax_add_to_cart add_to_cart_button product_type_simple ', $product->id);
$button = preg_replace('/(class="single_add_to_cart_button)/', $replacement, $button);
}
}
return $button;
}
function custom_woo_after_shop_loop() {
?>
<script>
jQuery(function($) {
<?php ?>
$("form.cart").on("change", "input.qty", function() {
$(this.form).find("button[data-quantity]").data("quantity", this.value);
});
<?php ?>
$(document.body).on("adding_to_cart", function() {
$("a.added_to_cart").remove();
});
});
</script>
<?php
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question