Support

Account

Home Forums General Issues Trouble with using ACF fields in cart

Unread

Trouble with using ACF fields in cart

  • I’m trying to add an ACF product field as a price suffix in the cart. (so it would for example show $11.00 / metre)
    I think it needs to know the product ID?
    I have used $product_id with get_field as seen in another post but it still does not work for me. What am I missing?

    
    add_filter( 'woocommerce_cart_item_price', 'ts_price_unit' );
    function ts_price_unit( $price) {
        $unit_type = get_field('unit', $product_id);   // ACF price per unit field eg. metre
        $afterPriceSymbol = '/';
        
      	return $price . $afterPriceSymbol . $unit_type ;
    }
        
Viewing 1 post (of 1 total)

The topic ‘Trouble with using ACF fields in cart’ is closed to new replies.