lundi 4 novembre 2019

Multiple "if" statements in PHP

I'm trying to add multiple "if" statements in my PHP but I'm having a hard time. I already read the answers to multiple posts here but none of them helped, I'm a little lost... Here is the code, which is supposed to change the price of a product in woocommerce.

function cw_change_product_html( $price_html, $product ) {
 if ( 2107 === $product->id ) {
 $price_html = '<span class="amount">A partir de 3.99€</span>';
 }
 else if ( 232 === $product->id ) {
 $price_html = '<span class="amount">A partir de 2.99€</span>';
 }
 return $price_html;
add_filter( 'woocommerce_get_price_html', 'cw_change_product_html', 10, 2 );
}

When there is only the first "if" it works perfectly, but when I try to add the second one, non of them works... what should I change?

Aucun commentaire:

Enregistrer un commentaire