Скрыть текст цены и скидки в раскрывающихся списках подписки WooCommercePhp

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Скрыть текст цены и скидки в раскрывающихся списках подписки WooCommerce

Сообщение Anonymous »


I want to remove the word "for", the pricing + discount sale and only display the subscription options like "Delivery every month" and "Delivery every 2 months," etc.

View product page

I've managed to change the text, but I'm having trouble removing the pricing. Here's the hook I'm using.
function wc_subscriptions_custom_price_string( $price_string ) { // First, replace 'every' with 'Delivery every' $new_price = str_replace('every', 'Delivery every', $price_string); // Now, use a regular expression to remove ' months for $X.XX' // This assumes that the price is always in the format of $ followed by any number of digits, a dot, and exactly two digits $new_price = preg_replace('/ months for \$\d+\.\d+/', '', $new_price); // Optionally, if you also want to remove the '(10% off)' part, you can add another line like this: // $new_price = preg_replace('/ \(.*?% off\)/', '', $new_price); return $new_price; } add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_custom_price_string' ); add_filter( 'woocommerce_subscription_price_string', 'wc_subscriptions_custom_price_string' );

Источник: https://stackoverflow.com/questions/780 ... wn-options
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Php»