显示不带html标签的产品变动价格

我想将产品变动价格提高一些百分比, 但是当我尝试获取变动产品价值时, 它附带了html代码, 但我需要整数值。

function woocommerce_variable_add_to_cart() {
    global $product, $post;
    $variations = $product->get_available_variations();
    foreach ($variations as $key => $value) {
       echo $value['price_html'];
    }
 }

#1


我认为你应该可以使用此display_price来获取价格:

function woocommerce_variable_add_to_cart() {
    global $product, $post;
    $variations = $product->get_available_variations();
    foreach ($variations as $key => $value) {
        echo $value['display_price'];
    }
 }

还有$ value [‘display_regular_price’]可用, 如果价格以某种方式降低, 则为原始价格。

来源:

https://www.srcmini02.com/64995.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37357.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?