Home Forums Front-end Issues Relationship field data override on single-product page


Relationship field data override on single-product page

  • Hi !

    I’m using ACF (version 5.80 – WP version 5.2) to display some informations on the single-product page (Woocommerce version 3.6.2).
    I succeed to display all the ACF I created except the relationship (link to object-article).
    The data displayed instead are the single-product page’s one…

    However the var_dump($values); display the good array…
    For example I have :
    array(3) { [0]=> string(4) “1208” [1]=> string(4) “1114” [2]=> string(4) “1102” }
    but the thumbnails, and everything else are (three times) the one of the product of the page and not the one of the ID of the array.

    Here is my code (in the functions.php of my child theme) :

    function relation_product() {
    	global $post;	
    	$product = wc_get_product( $post->ID );// Check for the custom field value
    	$title = $product->get_meta( 'prenomnom_auteur1' );// on récupère l'ID du post Auteur
    	if( $title ) {// Only display our field if we've got a value for the field title
    		$post_1 = get_post($title);
    		$values = get_post_meta( $title, 'du_meme_auteur', true);
    			echo '<ul>';
    			foreach($values as $article)
    				wc_get_template_part( 'content', 'product' );
    			echo '</ul>';
    	// always good to see exactly what you are working with
    add_action( 'woocommerce_after_single_product_summary', 'relation_product' );

    Can anyone help me ?



    PS : sorry for my english…

Viewing 1 post (of 1 total)

The topic ‘Relationship field data override on single-product page’ is closed to new replies.