• Hi,

    I want to change the product image used in Product Catalog. Instead of scraping the original Woocommerce Product image, I want images of an ACF field to be scraped. How can I config this?

    Thank you for reading and your help.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter kghugo2000

    (@kghugo2000)

    Hello?

    Plugin Author Antonino Scarfì

    (@antoscarface)

    Hi,

    sorry for the late response! You can only change the value of fields by operating into the code, by simply adding this snippet code at the end of the functions.php of your active theme:

    
    add_filter('aepc_feed_item', function($fields) {
    	$item_id = $fields['g:id'];
    	
    	// TODO HERE Get the new image link and assign to 'g:image_link'
    	$fields['g"image_link'] = '';
    	
    	return $fields;
    });
    

    Now, you just simply need to change $fields['g"image_link'] = ''; by assigning the value from your “ACF field”. Take in consideration that you have the $item_id if you need to get the field from a specific product post.

    Thread Starter kghugo2000

    (@kghugo2000)

    Great thank you for your help!

    Thread Starter kghugo2000

    (@kghugo2000)

    Hi,

    I am trying to understand the code here. The meta key for my ACF field is product_custom_feed_image, so is the following the right way to insert my field?

    
    add_filter('aepc_feed_item', function($fields) {
    	$item_id = $fields['g:id'];
    	
    	// TODO HERE Get the new image link and assign to 'g:image_link'
    	$fields['g"image_link'] = 'product_custom_feed_image';
    	
    	return $fields;
    });

    Thank you for reading and your help.

    Thread Starter kghugo2000

    (@kghugo2000)

    I tried to use that snippet but I got an “Invalid character error” . What should I do?

    Screenshot: https://monosnap.com/file/o5VXlVhLV26v3vyOwDqeDm9WZ5A7xg

    Plugin Author Antonino Scarfì

    (@antoscarface)

    Hi,

    if that 'product_custom_feed_image' is a post meta, you should just get it with get_post_meta function, in this way:

    `
    add_filter(‘aepc_feed_item’, function($fields) {
    $item_id = $fields[‘g:id’];

    // TODO HERE Get the new image link and assign to ‘g:image_link’
    $fields[‘g”image_link’] = get_post_meta($item_id, ‘product_custom_feed_image’, true);

    return $fields;
    });
    `
    Try it and let me know.

    Thread Starter kghugo2000

    (@kghugo2000)

    Hi,

    Thank you for the help. I have tried that code, but still it returns Invalid Characters Error. Is it related with the data in my database?

    Example for entry for that custom meta key: https://www.howtostudycantonese.com/wp-content/uploads/cover_feed_AESOP0016.jpg

    Is it possible that https or www the problem here?

    Thank you for your help.

    Plugin Author Antonino Scarfì

    (@antoscarface)

    Hi,

    I’m sorry I missed this reply and I’m seeing only now!

    I hope you found already the solution, but if you are still waiting, I noticed there was an error in the snippet I passed you before, in particular in ‘g”image_link which should be ‘g:image_link. That is the reason of the error. here the right code:

    
    add_filter(‘aepc_feed_item’, function($fields) {
    $item_id = $fields[‘g:id’];
    
    // TODO HERE Get the new image link and assign to ‘g:image_link’
    $fields[‘g”image_link’] = get_post_meta($item_id, ‘product_custom_feed_image’, true);
    
    return $fields;
    });
    
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Changing the product image to a ACF field in the catalog’ is closed to new replies.