How to add Upsells/Cross-sells to a product via PHP?
-
So I am receiving product details from an API. I have an array with the sku of the related products. How do I add those to the product using PHP?
What I am doing at the moment is this:
wp_set_object_terms($post_id, array(), ‘_crosssell_ids’);
update_post_meta( $post_id, ‘_crosssell_ids’, array());
…
$cross_sales = $products[‘Associated’];
update_post_meta( $post_id, ‘_crosssell_ids’, $cross_sales);
$products[‘Associated’] has in it for example [“AS11019″,”4046″,”AS11016″,”AS11014″,”AS11015″,”AS11017″,”AS11018”]
However this is not working. What am I doing wrong? Is there a better way to do it?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to add Upsells/Cross-sells to a product via PHP?’ is closed to new replies.