Customer Choices not on Gift Card?

Permalink Browser Info Environment
Hi! I have the gift cards working great as redeemable merchant coupons (like Groupon) except I have one problem. I adapted the mail overrides to be able to reference the order, product and billing objects so I could put more detail on the voucher (The name of the merchant, for example). I also added code that logged the order in a data file available to the specific merchant, and stored a copy of the voucher in a file for customer service.

(also you can see that in one place I made a global copy of the billing object in order to get at it here. yeah yeah I know I'm lazy like that sometimes )

Plus, I disabled the PIN number because I don't want people redeeming the coupons for cash value on the site.

I changed the 8 digit voucher code to a six digit numeric code that must be validated against a second number in the database (coupons are only redeemed by phone this way)

And I added a second number, an obfuscation of the order number that is cross-checked against the voucher code, that is not provided to the merchant, only printed on the voucher. The merchant must have this number to redeem the voucher (meaning, the purchaser must deliver it to him).

I set up an 800 number that interacts with the database to validate and redeem the vouchers. It decodes the voucher code and order number.

It all works great, and we've already made a few sales (meaning, me blindly tinkering with the site is not as big of an option as it was yesterday)

I only have one problem, the "Customer Choices: attributes are not displaying or being added to the value of the voucher. So, for instance, I have a $50 gym membership with a $30 "Second Person" upgrade. It checks-out okay and prints on the receipt, but not the voucher. The voucher only shows $50.

This is my /mail/giftcard_order_delivery.php. You can see around line 12 I tried to insert some code adapted from the order summary. but it does not display anything (just the newlines). Well, I can't be fiddling with all thumbs at this point. Can you help me correct where I'm wrong in trying to nab this information from the correct object or method?



<?php defined('C5_EXECUTE') or die("Access Denied.");
$mysix=strtr($dc['code'],'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', '222333444555666777788899990123456789');
$mysix=substr($mysix, 0, 6);
// obfuscate the orderID by adding it to the last 3 digits of the six, then adding 1000
$mypin=$coupon->getOrderProductID();
$mypin=1000+$mypin+substr($mysix,(3*-1));

$myfh = Loader::helper('file');
$myproduct=$coupon->getOrderProduct();

//$attribs = $myproduct->getProductConfigurableAttributes();
//$text = '';
//foreach($attribs as $ak) {
// $text .= $ak->render('label','',true) . ": " . $myproduct->getAttribute($ak, 'display')."," ;
//}


$myfn=$myfh->sanitize($myproduct->prName);
$myUsrDir = '/protected/vouchers/merchant/' . $myfn;
if (!file_exists($myUsrDir)) {mkdir ($myUsrDir);}
$myfile=$myUsrDir.'/'.date("Y-m-d").'.txt';
global $mybilling;
$abody = $mybilling['first_name'] . ",";
$abody .= $mybilling['last_name'] . ",";
$abody .= $mybilling['email'] . ",";
$abody .= $mybilling['address1'] . ",";
$abody .= $mybilling['address2'] . ",";
$abody .= $mybilling['city'] . ",";
$abody .= $mybilling['state'] . ",";
$abody .= $mybilling['zip'] . ",";
$abody .= $mybilling['phone'] . ",";
$abody .= $mysix . ",";
$abody .= CoreCommercePrice::format($dc['value']) . "\r\n";
$subject = t("You have a WAYTOMAIL.COM Voucher!");
$body .= sprintf(t('Your voucher has a base value of %s (plus any upgrades) that can be used at %s.'), CoreCommercePrice::format($dc['value']), $myproduct->prName ) . "\r\n\r\n";
$body .= $text . "\r\n\r\n";
$body .= t('Please use the following codes to make purchases with your gift voucher :') . "\r\n\r\n";
$body .= sprintf(t('VOUCHER CODE: %s'), $mysix ) . sprintf(t(' ORDER NUMBER: %s'), $mypin ) . "\r\n\r\n";
$body .= sprintf(t('Please print this email or write down your voucher code (%s) and order number (%s) and bring it to the merchant to redeem your purchase'), $mysix, $mypin) . "\r\n\r\n";
if ($expiration) {
$exp = date(DATE_APP_GENERIC_MDYT, strtotime($expiration));
$body .= sprintf(t("The amount paid for this voucher never expires. The promotional value expires on %s"), CoreCommercePrice::format($dc['value']), $exp) . "\r\n\r\n";
} else {
$body .= t('Your gift voucher NEVER EXPIRES.') . "\r\n\r\n";
}
$body .= t('How to use this VOUCHER:') . "\r\n\r\n" . t('Simply present your VOUCHER to the Merchant with the VOUCHER CODE and ORDER NUMBER to claim your pre-paid service.') . "\r\n\r\n";
$body .= t('Redeem at: ') . $myproduct->prName . "\r\n\r\n";
$body .= t('Refund Policy:') . "\r\n\r\n" . t('Way To Mail will provide a refund if you contact us 7 days after you’ve purchased your voucher. You can also use your voucher code and PIN as cash value to purchase other items on our website. Refunds are also provided in cases where you are unable to redeem a voucher because the merchant has gone out of business before the promotional period ends.') . "\r\n\r\n";
$body .= t('Rules and Regs:') . "\r\n\r\n" . t('All VOUCHERS will expire after 6 months of date of purchase. The amount PAID for the VOUCHER will never expire and can be applied toward a purchase offered by the merchant if the promotion is no longer available.') . "\r\n\r\n";
$body .= t('Contact Information:') . "\r\n\r\n" . t('For all information, please contact Way To Mail at 800-830-9994 or visithttp://www.WayToMail.com')... . "\r\n\r\n";
$body .= "----\r\n\r\n";
$body .= 'Email:'.$order->getOrderEmail() . " ";
$body .= '*'.$mysix.'/'.$mypin. "# ";
$body .= 'Invoice:'.$order->getInvoiceNumber() . " ";
$body .= 'Date:'.$order->getOrderDateAdded() . "\r\n\r\n";
file_put_contents($myfile,$abody,FILE_APPEND);
file_put_contents('/protected/vouchers/'.$mysix,$body,FILE_APPEND);
?>

Type: Discussion
Status: New
ErikLeeOlson
View Replies:
ErikLeeOlson replied on at Permalink Reply
ErikLeeOlson
This is the key:


$text .= $ak->render('label','',true) . ": " . $myproduct->getAttribute($ak, 'display')."," ;


This IS working, but it is generating HTML. I have to figure out how to display the properties of $ak.
Mainio replied on at Permalink Reply
Mainio
I'll check next week what's wrong with it. I think applying the customer choices should already be in the package itself. But I can believe this hasn't been thought out when developing this because the only customer choices with the originating client were like color, size, etc. which do not affect to the price.

But that just sounds a bit odd because if I can remember correctly, it should check the order total instead of product prices.

One more question, does your gift card set have "apply to the whole order" selected?

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.