hi simple scenario
wp+wc+ your plugin (if i buy it pro not yet sure)
product has SKU = 123456
i create a custom text field in the Products and i call it “CustomBarcode”
and i want to have the format “CBC-SKUnumberHere”
how can i do that?
i have only managed to add the “Prepend” “CBC-” how can i make it that this field is always this prepend PLUS the product SKU next to it?
also i would like this to be updated for all existing products in the database somehow…so that i dont have to open then and press “update” in wordpress.
is it possible? if so how?
thanks for your time and great tool.
I don’t see why you need a new custom field since this will just hold the SKU value with the “CBC-” prefix.
Why not just get the SKU where you need it and prefix it.
$bc = 'CBC-'.$product->get_sku();
Is there some other reason that you need to duplicate data?
i need to store this “new sku” in a separate field that will take part later in an XML feed export 🙂 and i dont have those options there to “generate the value” i really wish (with the prefix)
also where exactly do i put your code sample to get this result?
You would put the code wherever is is that you need to generate this value. It is just a generic example.
If you can edit the code, whether it is for an XML field or for showing the value on the site then you can generate the value in that location in the code as well.
The only reason you would not be able to do this is if you are not working in the code and you’re depending on something else to get the value and that value must be formatted correctly in the DB.
Even if you create the field it is not possible, at least not practically, to retroactively set this value for every product. You would need to do a query to get every single product and then update the field for each product one at a time.
So the question is, are you able to modify the code where you need this value to be used? Or is there some other thing that needs to use this value? Another plugin or setting that you haven’t mentioned?
thanks for your reply.
i am using a plugin to get my xml feed and there is no way (nothing that i have found at least) that i can edit a php file and modify my export.
thats why i was trying to come up with alternatives.
it seems my only options is to edit the mysql db directly…yet again is not the “correct” approach.
at the end of the day the goal was
property ProductID=ProductID OR if is Empty then ProductID=”CBC-“&& ProductSKU.
and since i dont have that “dynamic” attribute option in my plugin, i thought maybe i can use ACF to make an “intermediate” field publish it with the information i need and then use that in my xml.
so yeah is not 100% related to your tool, i was just trying to use your plugin to get into this alternative :/
thanks again for your time.
if you have any “ideas” to achieve this with ACF and some mysql sample code to try out and update the ACF fild, would be appreciated.
Most plugins allow you to add filters to what they output. What plugin are you using that is generating this XML?
unfortunately cant afford the “pro” version for just 1 site that i need that it says it allows you to “create dynamic” attributes.
this one, but i cant afford the “pro” version that says “it supports dynamic attributes”..
plugin costs are keep adding in these days. :/
“WooCommerce Product Feed for Google, Bing, eBay and Many More
and i cant afford the pro version to get what i need so i am looking for alternatives.
dear John is ok forget it….i found a way to get what i need from this expensive plug in 😉
thanks for your time! much appreciated.
Hi I an trying to acheive a similar result as you. Any chance you can fill me in on how you found the answer? thanks.
@johnnyxp64 your replies all went into spam, so I did not see them. I looked that that plugin and there is a way to customize the xml feeds by providing custom templates. I don’t know if this requires the pro version or not, but the documentation they provide and modifications will need to be made there and cannot be effected by ACF.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Merry Christmas and Happy Holidays WordPress Family 🎄🤗— Advanced Custom Fields (@wp_acf) December 24, 2020
© 2021 Advanced Custom Fields. Subscribe