/** * how much is this voucher worth * * @param string $code the voucher code * @param string $email the email address of the user * @param float $grandTotal the value of the basket * * @return float the value of the voucher */ function OnlineStore_voucherAmount($code, $email, $grandTotal) { $voucher = OnlineStore_voucherCheckValidity($code, $email); if (@$voucher['error']) { return 0; } $value = (double) $voucher['value']; if ($value < 0) { $value = 0; } if ($voucher['value_type'] == 'percentage') { if ($value > 100) { $value = 100; } return $grandTotal * ($value / 100); } return $value > $grandTotal ? $grandTotal : $value; }
$_REQUEST['_payment_method_type'] = 'PayPal'; } elseif (@$PAGEDATA->vars['online_stores_quickpay_merchantid']) { $_REQUEST['_payment_method_type'] = 'QuickPay'; } elseif (@$PAGEDATA->vars['online_stores_realex_sharedsecret']) { $_REQUEST['_payment_method_type'] = 'Realex'; } elseif (@$PAGEDATA->vars['online_stores_bank_transfer_account_number']) { $_REQUEST['_payment_method_type'] = __('Bank Transfer'); } } // } // { if a voucher is submitted, check that it's still valid if (@$_REQUEST['os_voucher']) { require_once dirname(__FILE__) . '/voucher-libs.php'; $email = $_REQUEST['Email']; $code = $_REQUEST['os_voucher']; $valid = OnlineStore_voucherCheckValidity($code, $email); if (isset($valid['error'])) { $errors[] = $valid['error']; } } // } // { check that payment method is valid switch ($_REQUEST['_payment_method_type']) { case 'Bank Transfer': // { if (!@$PAGEDATA->vars['online_stores_bank_transfer_account_number']) { $errors[] = __('Bank Transfer payment method not available.'); } break; // } // }
/** * check a voucher to see if it's valid * * @param array $params parameters * * @return array success status */ function OnlineStore_checkVoucher($params) { require_once dirname(__FILE__) . '/frontend/voucher-libs.php'; if (!isset($params['code']) || !isset($params['email'])) { return array('error' => __('Invalid or missing parameters')); } $valid = OnlineStore_voucherCheckValidity($params['code'], $params['email']); if ($valid['error']) { return $valid; } else { return array('ok' => 1); } }