Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hopefully a nice simple question to start the day...

In success.phtml, I would like to achieve the following using PHP:

$_commissionGroupCode = [If $_voucher is empty, echo "DEFAULT". Else echo "VOUCHER"]

Below is a snippet of my code so far:

$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId(); 
$order = Mage::getModel('sales/order')->load($lastOrderId);
$_products = $order->getAllItems();

$_totalData = $order->getData(); 
$_discount = $_totalData['discount_amount'];
$_voucher = $_totalData['coupon_code'];
$_commissionGroupCode = ANSWER GOES HERE

You will notice I already have $_voucher to call the voucher code

share|improve this question
2  
I'm voting to close this question as off-topic because this is a PHP only question. – Raphael at Digital Pianism yesterday
    
But it may help others trying to achieve integration between Affiliate Window Services and Magento – Craig yesterday
up vote 1 down vote accepted

You can do it like this:

$_commissionGroupCode = (!$_voucher ? "DEFAULT" : "VOUCHER");
share|improve this answer

You can achieve this in one line with a ternary operator

$_commissionGroupCode = ($_voucher ? 'VOUCHER' : 'DEFAULT');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.