Woocommerce 购物车展示

问题描述 投票:0回答:0

我有 woocommerce 动态价格的产品。我无法在购物篮中显示这些产品的价格。有没有人可以帮忙。非常感谢您。

add_filter( 'woocommerce_get_price_html', 'bbloomer_alter_price_display', 100, 2 );  
add_filter( 'woocommerce_cart_item_price', 'bbloomer_alter_price_display', 10, 3 ); 
  
function bbloomer_alter_price_display( $price_html, $product ) { 
    // ONLY ON FRONTEND
    if ( '' === $product->get_price() ) return $price_html; 
        $attributes = $product->get_attributes();
        foreach ( $attributes as $attribute ) {
        // Get the taxonomy.
        $terms = wp_get_post_terms( $product->id, $attribute[ 'name' ], 'all' );
        $taxonomy = $terms[ 0 ]->taxonomy;

        // Get the taxonomy object.
        $taxonomy_object = get_taxonomy( $taxonomy );

        // Get the attribute label.
        $attribute_label = $taxonomy_object->labels->singular_name;// Base qualification take
        $qualification= get_the_term_list( $post->ID, $attribute[ 'name' ]);//goldcarat
 
        $start=strpos($qualification,"term="); 
      
        $goldcarat=substr($qualification,$start+5); 
        $endd=strpos($goldcarat,"rel");
        $goldcarat=substr($qualification,$start+5,$endd-2);
        $rate=SetGoldRate($goldcarat);
 
        $orig_price = wc_get_price_to_display( $product )*$rate;
        $price_html =wc_price( $orig_price);
    
    return $price_html;
 
} 

我有 woocommerce 动态价格的产品。我无法在购物篮中显示这些产品的价格。有没有人可以帮忙。非常感谢您。

woocommerce
© www.soinside.com 2019 - 2024. All rights reserved.