Мне нужна твоя помощь. Я нашел это, чтобы добавить цену прямо на кнопку Добавить в корзину.
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_price', 20, 2 );
// Shop and other archives pages
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_price', 20, 2 ); // Single product pages
function custom_add_to_cart_price( $button_text, $product ) {
// Variable products
if( $product->is_type('variable') ) {
// shop and archives
if( ! is_product() ){
$product_price = wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_variation_price() ) ) );
return $button_text . ' - From ' . strip_tags( $product_price );
}
// Single product pages
else {
return $button_text;
}
}
// All other product types
else {
$product_price = wc_price( wc_get_price_to_display( $product ) );
return $button_text . ' - Just ' . strip_tags( $product_price );
}
}
Хороший фрагмент. Оно работает. Как я могу исключить указанный c продукт? Потому что с подарочными картами YITH отображается просто «Добавить на карту - 0 €».
Или, как я могу отобразить цену вариации с помощью "Yith Gift Card", когда клиент выбирает указанную c цену или вводит ее вручную?
Самым простым будет скрыть цену, но это будет здорово, что цена меняется прямо на кнопке.
Источник: Отображение цены на кнопку добавления в корзину из функций. php файл в Woocommerce
Спасибо за ваша помощь.