Beispiel #1
0
 function addGiftCertificate()
 {
     global $toC_Json, $osC_Language, $osC_ShoppingCart, $osC_Currencies, $osC_Weight, $osC_Tax;
     $osC_Tax = new osC_Tax_Admin();
     $osC_Weight = new osC_Weight();
     $osC_Currencies = new osC_Currencies();
     $osC_Language->load('checkout');
     $osC_ShoppingCart = new toC_ShoppingCart_Adapter($_REQUEST['orders_id']);
     $errors = array();
     if ($osC_ShoppingCart->isTotalZero()) {
         $errors[] = $osC_Language->get('error_shopping_cart_total_zero');
     }
     if ($osC_ShoppingCart->containsGiftCertifcate($_REQUEST['gift_certificate_code'])) {
         $errors[] = $osC_Language->get('error_gift_certificate_exist');
     }
     if (!toC_Gift_Certificates::isGiftCertificateValid($_REQUEST['gift_certificate_code'])) {
         $errors[] = $osC_Language->get('error_invalid_gift_certificate');
     }
     if (sizeof($errors) == 0) {
         $osC_ShoppingCart->addGiftCertificateCode($_REQUEST['gift_certificate_code']);
         $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
     } else {
         $response = array('success' => false, 'feedback' => $errors);
     }
     echo $toC_Json->encode($response);
 }
 function redeemGiftCertificate()
 {
     global $toC_Json, $osC_Language, $osC_Payment, $osC_ShoppingCart, $osC_Currencies;
     $osC_Language->load('checkout');
     $errors = array();
     if ($osC_ShoppingCart->isTotalZero()) {
         $errors[] = $osC_Language->get('error_shopping_cart_total_zero');
     }
     if ($osC_ShoppingCart->containsGiftCertifcate($_POST['gift_certificate_code'])) {
         $errors[] = $osC_Language->get('error_gift_certificate_exist');
     }
     if (!toC_Gift_Certificates::isGiftCertificateValid($_POST['gift_certificate_code'])) {
         $errors[] = $osC_Language->get('error_invalid_gift_certificate');
     }
     if (sizeof($errors) == 0) {
         $osC_ShoppingCart->addGiftCertificateCode($_POST['gift_certificate_code']);
         $form = toC_Json_Checkout::_getPaymentMethodForm();
         $response = array('success' => true, 'form' => $form, 'isTotalZero' => $osC_ShoppingCart->isTotalZero());
     } else {
         $response = array('success' => false, 'errors' => $errors);
     }
     echo $toC_Json->encode($response);
 }