I have the following code to remove a string if it contains the word "from" for each product on the page. This works well, but I only want to delete it one place for each product. (The string exists in two places for each product.)
$sub_notags = strip_tags( $subscription_string );
if ( strpos( $sub_notags, 'From:') !== false ) {
return '';
}
Here's the HTML output of the place where I want it to work:
<label class="product_checkbox">Add <span class="price-string">From $68.00 on October 3rd each year</span></label>
And here's the place I want to ignore:
<span class="price"><span class="price-string">From $68.00 on October 3rd each year</span></span>
Update: I tried using strstr instead of strpos, because PHP docs said that should "find the first occurrence of a string". But that isn't working either. It is still affecting all occurrences.
Update2: Here is $subscription_string
:
// translators: 1$: recurring amount, 2$: month (e.g. "March"), 3$: day of the month (e.g. "23rd") (e.g. "$15 on March 15th every 3rd year")
$subscription_string = sprintf( __( '%1$s on %2$s %3$s every %4$s year', 'woocommerce-subscriptions' ), $price, $wp_locale->month[ $payment_day['month'] ], WC_Subscriptions::append_numeral_suffix( $payment_day['day'] ), WC_Subscriptions::append_numeral_suffix( $billing_interval ) );
}
And here's a var_dump of $subscription_string
:
string(199) $68.00 on October 3rd each year