• How can I (automatically) copy (on product update) a Woocommerce product Attribute to a Custom Field?
    Does anyone have any code for this?

    I’m using plugin, WordPress Meta Data & Taxonomies Filter (MDTF). While most filter options can be created with WC Product Attributes.
    In order to create a range slider it only work with Custom Fields. It does not work with product attributes.

    While I could manually add the data in Custom Fields, the data is already contained as a product attribute. I don’t want to manually have to add it twice and risk any inconsistencies. Plus client does not need know anything about custom fields.

    Does anyone know of any (php) code to do this?

    https://www.ads-software.com/plugins/woocommerce/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Actually, attribute values will already be saved to postmeta – the postmeta key is something like attribute_pa_<attributename>

    Thread Starter Sogwap

    (@sogwap)

    That’s not what I need.

    I need for the designated product attribute to be automatically saved as a Custom Field.

    Which product attribute do you need this done to?

    Thread Starter Sogwap

    (@sogwap)

    Attribute
    Name: Alchohol %
    Slug: alchohol-percentage

    Custom Field: alchohol_percentage

    Here’s another:
    Attriute:
    Name: Price Bottle
    Slug: price-bottle

    Custom Field: price_bottle

    Note: Attribute will have only one value.

    I’d look at using the ‘save_post’ action

    https://codex.www.ads-software.com/Plugin_API/Action_Reference/save_post

    You could check to see if it’s not an autosave and if the post_type = product and then grab the attribute(s) you want and then use update_post_meta function to add/update specific custom fields.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Copy Woocommerce Product Attributes to Custom Fields’ is closed to new replies.