• Resolved thesun1

    (@thesun1)


    Hi,

    I’m trying to read the unit_product metadata from a localized product.
    This works for the base (english) product:
    get_post_meta( $_product->get_id(), '_unit_product', true);

    but the unit metadatas are not available when the product ID is the one of the localized product. Is there an easy way to access this or should I get the orignial ID and call get_post_meta with the original product only?

    More info:
    the var_dump of the localized simple product shows that the meta keys for “unit” are available but somewhere hidden inside this:

    ["gzd_product"]=> object(WC_GZD_Product)#11978 (3) { ["child":protected]=> *RECURSION* ["gzd_variation_level_meta":protected]=> array(7) { ["unit_price"]=> string(0)

    Any help is appreciated!

    Regards,
    thesun1

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author vendidero

    (@vendidero)

    Hi there,

    which plugin are you using for localization? Generally the post_meta approach should always work (if data exists). I don’t know how your localization plugin works, but maybe it uses english data as fallback and for the localized product there is no specific unit price available (which otherwise would be located within the post_meta table).

    The object just serves as a wrapper to abstract from the data layer.

    cheers

    Thread Starter thesun1

    (@thesun1)

    Hey,

    thanks for the quick reply.
    I’m using WPML with WooCommerce Multilingual and Woocommerce germanized.

    The bug was not easy to find, because the code works when there is an english product in the cart, but as soon as the product is a translated version (german) it looses access to these fields from the main product.
    This also results in the storefront_pricing_tables plugin no longer showing per unit price for these products.

    Short recap: The custom taxonomy (unit_product) does not seem to be accessible on a product translated with woocommerce multilingual. Do you have any idea how I can make wpml and germanized play well together on this?

    Best Regards

    Thread Starter thesun1

    (@thesun1)

    Sorry,
    any chance you could look into this again?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to access _unit_product post meta?’ is closed to new replies.