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 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.
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. :/
@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!
© 2022 Advanced Custom Fields.