WooCommerce Automatic Cross-Sells

This is possibly a big ask but i’ll go for it in the hope that someones light bulb comes on.

I’m importing products into WooCommerce using WP All Import to process a data feed, i’ve managed to learn a few tricks on here over the last couple of years to really map every single part of the product how i want it. The only part of the feed which is not yet automated is Cross-Sells. What i would like to do is run a custom function on the cross-sells field to automatically match a product based on title. This may sound a little complicated but the products in question do have something in common.

The first 2 words of the relevant products are matching and unique. Ex

Product 1 = Gracya Bellissimo Bra
Product 2 = Gracya Bellissimo Thong

So would there be a anyway, using php, that i could get the cross-sells field to automatically choose to cross-sell Product 2 on Product 1 and vice versa ?

Thanks for any help or pointers !

This would be going into a database column, correct? And those titles are also stored in a database column?

I believe the title is produced exactly the same as Wordpress posts <?php the_title( ); ?> and I believe that cross-sells may be stored as post meta but I’m really not certain.

Investigate the table design first and get back with us

Sponsor our Newsletter | Privacy Policy | Terms of Service