Support

Account

Home Forums General Issues Add ACF field of single product page Reply To: Add ACF field of single product page

  • As a quick after thought, you *may* need to access the product ID to get the data from the field, if so, try:

    add_action( 'woocommerce_before_add_to_cart_form', 'my_pdf_field' );
    function my_pdf_field() {
    	
    	global $product;
    	$product_id = $product->get_id();	
    
    	$pdf = get_field( 'pdf', $product_id );
    	#if we have data, show it
    	if( $pdf ){
    		echo '<a href="'.$pdf['url'].'">link</a>';
    	}
    	
    }