} } } else { if ($transaction->anet_CIM(false)) { // success if (!empty($order_weekday->meals)) { $dbi->update('Orders', array('TransactionNumber' => $transaction->PymtRefCd), array('OrderID' => $order_weekday->OrderID)); $_SESSION['successWeekly'][] = $order_weekday->OrderID; } if (!empty($order_weekend->meals)) { $dbi->update('Orders', array('TransactionNumber' => $transaction->PymtRefCd), array('OrderID' => $order_weekend->OrderID)); $_SESSION['successWeekly'][] = $order_weekend->OrderID; } } else { // anet error Gadget::add_message("Error while processing Order {$orderID} - " . $transaction->get_error_message()); //die($transaction->get_error_message()); $orderSuccess = false; } $krustomer->First_Order_Date = $krustomer->First_Order_Date ? $krustomer->First_Order_Date : $date; $krustomer->Last_Order_Date = date('Y-m-d'); $krustomer->Total_Orders++; $krustomer->update(); $orderSuccess = true; // If they used a promocode that was an ammount, subtract total from promocode amount if ($promoCode->multiple_use == 0) { if ($promoCode->Amount > 0 && $promoCode->PromoCodeType == "Amount Discount") { $newPromoCodeAmount = $promoCode->Amount - $order->Amounts->Subtotal->amount; if ($newPromoCodeAmount < 0) { $newPromoCodeAmount = 0; }
if ($PromoCode && $PromoCode->can_be_used($_SESSION['CustomerID'], 'GiftCertificates')) { $promoCodeAmount = intval($PromoCode->Amount); $giftCertAmount = intval($data['GiftAmount']); $newPromoCodeAmount = $promoCodeAmount - $giftCertAmount; if ($newPromoCodeAmount < 0) { $newPromoCodeAmount = 0; } $dbi->update('PromoCodes', array('Amount' => $newPromoCodeAmount), array('PromoCodeID' => $PromoCodeID)); } } //Gadget::add_message('success'); Gadget::redirect('success2'); } else { Gadget::add_message($transaction->get_error_message()); } } catch (Exception $e) { s('Error: ' . $e->getMessage() . $transaction->get_error_message()); Gadget::add_message($e->getMessage() . $transaction->get_error_message()); } } } $page = Page::get_from_alias('giftcertificates'); $page->add_js('/js/giftcertificates.js'); require 'header.php'; ?> <div class="content-padding"> <div><?php echo $page->content['main']; ?></div>
$krustomer->Last_Order_Date = $date; $krustomer->Total_Orders++; $krustomer->update(); //make sure there is an order record //@golive change date - Gadget::$date_do->format(DATE_FORMAT_MYSQL) $insert_data = array( 'CustomerID' => $krustomer->CustomerID, 'DeliveryDate' => $sub->DeliveryDate, 'DateOrdered' => array('NOW()', ''), 'Total' => 0, ); //$dbi->insert('Orders', $insert_data, array(), 'IGNORE'); } else { // anet error echo "Error while processing subscription for Customer $sub->CustomerID - {$transaction->get_error_message()}"; b(); } } else { echo "Can't process subscription for Customer $krustomer->CustomerID - missing authorize.net profiles"; b(); } h(); } //insert new subscription rows /* $dbi->q(" INSERT IGNORE INTO Subscriptions (DeliveryDate, CustomerID, WeeklyMeals, WeeklyReg, WeeklyVeg) SELECT DATE_ADD('$date', INTERVAL 6 DAY) AS DeliveryDate, CustomerID, WeeklyMeals, WeeklyReg, WeeklyVeg FROM Customers