Hi I would like to automatically save a value for a cf when a product is created or updated. Is this possible? Now I need to manually save the products to get the auto value for this cf saved with the product.
in here that I need for a specific link to get the SKU field linkable as I can't insert a custom link in the Products Tabel from Barn2.co.uk.That's why I need to solve this by putting the link in a custom field as far as I know at least.
The WP All import fails on the '$' sign when including the link in the import, which would be the easiest way to go with. That is why I thought I could solve it by having the value saved automatically. I have looked at the link, but I am not sure. I simply have too little experience with PHP to get this done. Hope you point me in the right direction. Thanks.
Because of the new relationship method, this actually won't work in the link [wpv-post-id id=“$parent”]
Is the parent in another custom post type ?
If so then your selector for the parent data would look something like [wpv-post-id item='@manufacturer-car.parent'] where manufacturer-car in my case is the relationship slug.
Hi Shane
Thanks for your comment. I do not use the link for a CPT or relation. I use the link to show extra information for a WooCommerce product variation. Please check the link below for a live demo. De SKU in the variation table links to a page with extra product variation info called a datasheet. This is where the link is used for. It filters the custom view on these 2 values (product_id & variation_id)
The plugin form the people at Barn2 works really nice, but it doesn't allow me to add a custom link. That's why i've created a CF with the link. But this link doesn't get saved automatically when a product is created or updated by import.
So you essentially want populate the custom field when the post is being created.
I'm still a little confused about the use of [wpv-post-id id=“$parent”] , this to me suggest there is a Post relationship here. That you are trying to get the Parent ID of that post.
I need some clarity on this before we can proceed.
Notice I change to the use of "" single quotes around the $parent. You can try importing it with the links like this to see if it works. The other alternative is to contact the WP all import plugin team to see why the $ is breaking the import.
Any other solution that I can provide will require the manual creation of the products where I would use the save post hook to populate the custom field.
Thanks. Unfortunately WP All Import doesn't allow single quotes. Same goes for the $ sign. I do have an option to execute a function form within the import. Could this be something we could use?
This might be able to work but not sure how this editor here works.
Perhaps you can ask the WP All Import team if their import fires the save_post hook ? If it does then we can write a hook here that will hook into the save post to populate the field for you.
Please try this and let me know if it helps.
Given that the mentioned information that the WP All imports team says the php hooks are fired here then this should work.
Sorry wasn't able to respond for a while. Thanks a lot. Unfortunately the script throws an error like shown in the image. According to Google this could be due to an old PHP version (below 7.x) on my webserver. I have checked and it 7.3.5, so this seems to be oke. What should I do?