• Resolved doctordisco

    (@discomidget)


    I wanted to be able to use a second sku number assigned to my products. I was able to create a custom field ‘ stock# ‘ for my products by exporting from Woocommerce and adding a column, Meta: stock#, then importing. It worked and I am able to export, create reports in Excel and modify products, pricing etc. as well as the stock# and import. As expected, I can’t see the meta field in the Woocommerce backend or on invoices. Now I’m trying to show the meta – custom field by using php code/hooks in the plugin: code snippets. I’m getting a syntax error. Before I troubleshoot that further, I wanted to know if using the character ‘ # ‘ is a bad idea and could be causing the problem. I don’t know if this is a general coding rule or specific to php. If using the character ‘ # ‘ is not a problem, I’ll continue to troubleshoot code snippets etc. If it is a problem, what would be the way to change it since I can’t see meta data – custom fields in the backend? Would I export products to csv and change the column header from ‘ meta: stock# ‘ to something like ‘ meta: sku2 ‘ ? I searched the Woocommerce documentation, but didn’t see that using charcters like ‘ # ‘ was mentioned. I don’t know if there are rules to creating custom fields. I didn’t know if using ‘ sku ‘ again in ‘ sku2 ‘ might even create a problem. Maybe this is common sense, but I don’t know. Thanks for your help. I’m not familiar with coding and will start by learning about php. Any recommended resources are greatly appreciated.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter doctordisco

    (@discomidget)

    From what I’ve gleaned, the safest name for meta fields are: alpha-numeric characters and underscores (A-z, 0-9, and _ ). Although I haven’t found anything specifically saying this, other characters seem to cause different behaviors in PHP and I don’t know about javascript, but I guess it’s the same. If it’s safe to do so, I’ll follow the steps above: ‘export products to csv and change the column header from ‘meta: stock#‘ to something like ‘meta: sku2 ‘ or ‘meta:SKU_2’. I don’t know if upon re-importing, if it will change the column header or simply create another column in addition to ‘meta: stock#’

    Thread Starter doctordisco

    (@discomidget)

    I could not modify visibility of meta: custom fields in the admin backend until exported products to csv using the included export/import function. I clicked the box to ‘include meta’ changed the column header in Google sheets (to preserve file integrity) then imported, checking the box again. When it showed the columns being imported, it showed meta: sku_RE. By changing meta: stock# to meta: sku_RE, I fixed the compatibility error I was having and used code snippets and PHP to now see the meta custom field on orders.

    Saif

    (@babylon1999)

    Hello @discomidget,

    Glad to hear you’ve figured it out!

    I tried adding new custom fields and importing it to other products but I can see it in the backend, so I don’t think it had to do with a character limit.


    Link to image: https://d.pr/i/wgt0NN

    I will keep the thread marked as solved for now, if you have any new findings about this or believe you have found a bug, please don’t hesitate to let us know.

    Cheers! :?)

    Thread Starter doctordisco

    (@discomidget)

    Thanks. I was definitely able to import ‘stock#’ as a meta: custom field. It was presenting a problem later when I was trying to use that custom field.

    Hi @discomidget

    You are most welcome and we’re glad that worked! ??

    Meanwhile, if you have a moment to spare, we would love it if you could share your thoughts with us by leaving a review or feedback. Your experience and feedback are important to help us improve and ensure we’re always providing the best possible support.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Meta – Custom Field illegal characters or syntax rules’ is closed to new replies.