Wordpress Function

Hi folks, total novice at php so i’m hoping someone can help me here.

I want to automatically fill a field in wordpress/woocommerce based on certain conditions.

I have lots of products on my site and i’m wish to update a field for google shopping, but currently only a manual action exists.

So my example is Product 1 has 2 categories > Hugo Boss & Shirts and Product 2 has 2 categories True Religion & Jeans
these are in the field product_cat. I some how need a function to apply the product_cat to _woocommerce_gpf_data but only the brand if Hugo Boss or True Religion exists in product_cat.
If thats not complicated enough, then _woocommerce_gpf_data is serialised too in the following format [php]a:1:{s:5:“brand”;s:3:“Hugo Boss”;}[/php]

I appreciate this is a tall order, but if anybody can assist i’d greatly appreciate it.

Thanks again !

Did you change the brand name in that serialized string? Asking because what you posted is invalid.

Are you writing a script that will run when viewing a product, or a script that will iterate over all products in the database and update them. Either way you should add some code where you have a product to work with (either in a loop or alone)

Product 1 in your example. Should both Hugo Boss & Shirts be added to _woocommerce_gpf_data? Or just Hugo Boss?

Sponsor our Newsletter | Privacy Policy | Terms of Service