Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Output product variation value from order WooCommerce WordPress

Hi

I am trying to customise Gift Certificates Pro plugin so that the variation value is printed onto the certificate rather than the value.

I can see where the amount is being passed through but can't seem to find a way to change this so that it sends through the variation value (text) instead.

The create pdf function is passed:

function create_pdf( $order_id, $voucher_id, $msg_details = array(), $item, $voucher_code, $amount, $product_id )

The $amount variable is set using:

global $post, $woocommerce, $product;

$coupon = get_post_meta( $post->ID );

$amount = $coupon['coupon_amount'][0];


The item date passed through to the PDF Generation function is:

$item_data = array(
'voucher_number' => $voucher_id,
'voucher_expiration' => '', // should be a date time string to be used by strtotime().
'data' => $msg_details, //product name MAKE THIS AVAILABLE IN THE HTML TEMPLATE FILE
'voucher_image_id' => $images[0], //image selected by shopper
'name' => '', // product name
'item' => $item, // order item object
'coupon_id' => $this->get_coupon_id( $voucher_code ),
'expiry' => $expiry,
'coupon_code' => $voucher_code,
'coupon_amount' => $amount,
'product_desc' => $desc,

);


So I need a way to simply replace $amount with the variation value (the variation is called Guests).

Hope that explains what I am trying to do

Answers (3)

2014-10-23

Sabby Sam answers:

Hi Vaislade,
I can assist you, but need to read your whole plugin structure. Please give us some access to the site.
thanks

2014-10-23

zebra webdesigns answers:

Hello Navislade,

can you pass me the login credentials and FTP detail.
If you can do it by yourself, I can assist you through teamviewer or skype.
MY skype ID: bhuvan530531

2014-10-23

Arnav Joy answers:

try this

<?php

global $post, $woocommerce, $product;



$coupon = get_post_meta( $post->ID );



$amount = $coupon['coupon_amount'][0];

$available_variations = $product->get_available_variations();
$variation_id=$available_variations[0]['variation_id'];
$variable_product1= new WC_Product_Variation( $variation_id );
$regular_price = $variable_product1->regular_price;
$sales_price = $variable_product1->sale_price;
?>

now you can use $regular_price or $sales_price for $amount

Let me know if it helps