WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] get_post_meta to get custom field data (6 posts)

  1. ribamar23
    Member
    Posted 2 years ago #

    Hi

    I need to define a custom field in woocommerce produts (integer value) and need to access it in another plugin.

    In that plugin I can already access woocommerce data via

    $order_total = get_post_meta( $order_id, '_order_total', true );

    If I define a custom field named "xpto", how can I get its data to a variable?

    hope someone can help

    cheers

    http://wordpress.org/extend/plugins/woocommerce/

  2. ribamar23
    Member
    Posted 2 years ago #

    i tried this

    public static function woocommerce_get_price( $product_id ) {
    		$price = get_post_meta($product_id, '_price', true );
    	 }

    and then

    $amount = round( floatval( $referral_rate ) * floatval( $price ), AFFILIATES_REFERRAL_AMOUNT_DECIMALS );

    but it's not working

    I'm using Affiliates Integration with Woocommerce
    I need to define different comissions for each product...

    I can create a custom field when inserting a new product called commission then insert the commission, then in the file affiliates-woocommerce-light.php I need to access to that value defined for commission......

    any help please?

  3. ribamar23
    Member
    Posted 2 years ago #

    or may it's better if I in the order class have a variable to calculate toal product commissions (commission product A + commission product B + ...) and then access that variable in affiliates-woocommerce-light.php..... what do you think?

  4. ribamar23
    Member
    Posted 2 years ago #

    how is it possible to return a value of a custom field?

  5. ribamar23
    Member
    Posted 2 years ago #

    var $product_custom_fields;

    is that it?

  6. mikejolley
    Member
    Plugin Author

    Posted 1 year ago #

    If I define a custom field named "xpto", how can I get its data to a variable?

    get_post_meta( $order_id, 'xpto', true );

    You need to know the $order_id though of course.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic