public function manage_promocodes() { expHistory::set('manageable', $this->params); $pc = new promocodes(); $do = new discounts(); $promo_codes = $pc->find('all'); $discounts = $do->find('all'); assign_to_template(array('promo_codes' => $promo_codes, 'discounts' => $discounts)); }
function checkout() { global $user, $order; $cfg->mod = "cart"; $cfg->src = "@globalcartsettings"; $cfg->int = ""; $config = new expConfig($cfg); $order->calculateGrandTotal(); $order->validateDiscounts(array('controller' => 'cart', 'action' => 'checkout')); if (!expSession::get('customer-signup') && !$user->isLoggedin()) { expHistory::set('viewable', $this->params); flash('message', gt("Please select how you would like to continue with the checkout process.")); expHistory::redirecto_login(makeLink(array('module' => 'cart', 'action' => 'checkout'), 'secure')); } if ($order->total < intval($config->config['min_order'])) { flashAndFlow('error', "Note: Thank you for your decision to purchase. However, our minimum order for merchandise is \$" . number_format($config->config['min_order'], 2, ".", ",") . ". Please increase your quantity or continue shopping."); } if (empty($order->orderitem)) { flashAndFlow('error', 'There are no items in your cart.'); } $billing = new billing(); //eDebug($billing,true); if (count($billing->available_calculators) < 1) { flashAndFlow('error', 'This store is not configured to allow checkouts yet. Please try back soon.'); } // set a flow waypoint expHistory::set('viewable', $this->params); //this validate the discount codes already applied to make sure they are still OK //if they are not it will remove them and redirect back to checkout w/ a message flash //$order->updateOrderDiscounts(); //eDebug($order); // are there active discounts in the db? $discountCheck = new discounts(); $discountsEnabled = $discountCheck->find('all', 'enabled=1'); if (empty($discountsEnabled)) { // flag to hide the discount box assign_to_template(array('noactivediscounts' => '1')); $discounts = null; } else { // get all current discount codes that are valid and applied $discounts = $order->getOrderDiscounts(); } //eDebug($discounts); /*if (count($discounts)>=0) { // Mockup code $order->totalBeforeDiscounts = $order->total; // reference to the origional total $order->total = $order->total*85/100; // to simulate 15% } */ // call each products checkout() callback & calculate total foreach ($order->orderitem as $item) { $product = new $item->product_type($item->product_id); $product->checkout(); } // get the specials...this is just a stub function for now. $specials = $this->getSpecials(); // get all the necessary addresses..shipping, billing, etc $address = new address(); //$addresses_dd = $address->dropdownByUser($user->id); $shipAddress = $address->find('first', 'user_id=' . $user->id . ' AND is_shipping=1'); if (empty($shipAddress) || !$user->isLoggedin()) { expSession::set('customer-signup', false); flash('message', gt('Step One: enter your primary address info now.') . '<br><br>' . gt('You may also optionally provide a password if you would like to return to our store at a later time to view your order history or make additional purchases.') . '<br><br>' . gt('If you need to add another billing or shipping address you will be able to do so on the following page.')); redirect_to(array('controller' => 'address', 'action' => 'edit')); } // get the shipping calculators and the shipping methods if we need them $shipping = new shipping(); //$shipping->shippingmethod->setAddress($shipAddress); //FJD? //$shipping->getRates(); assign_to_template(array('cartConfig' => $config->config, 'shipping' => $shipping, 'user' => $user, 'billing' => $billing, 'discounts' => $discounts, 'order' => $order, 'order_types' => $order->getOrderTypes(), 'default_order_type' => $order->getDefaultOrderType(), 'order_statuses' => $order->getOrderStatuses(), 'default_order_status' => $order->getDefaultOrderStatus(), 'sales_reps' => $order->getSalesReps())); }
function order_report() { // stub function. I'm sure eventually we can pull up exising reports to pre-populate our form. $os = new order_status(); $oss = $os->find('all'); $order_status = array(); $order_status[-1] = ''; foreach ($oss as $status) { $order_status[$status->id] = $status->title; } $ot = new order_type(); $ots = $ot->find('all'); $order_type = array(); $order_type[-1] = ''; foreach ($ots as $orderType) { $order_type[$orderType->id] = $orderType->title; } $dis = new discounts(); $diss = $dis->find('all'); $discounts = array(); $discounts[-1] = ''; foreach ($diss as $dkey => $discount) { $discounts[$discount->id] = $discount->coupon_code; } /*$geo = new geoRegion(); $geos = $geo->find('all'); $states = array(); $states[-1] = ''; foreach ($geos as $skey=>$state) { $states[$skey] = $state->name; } */ $payment_methods = billingmethod::$payment_types; $payment_methods[-1] = ""; ksort($payment_methods); //array('-1'=>'', 'V'=>'Visa','MC'=>'Mastercard','D'=>'Discover','AMEX'=>'American Express','PP'=>'PayPal','GC'=>'Google Checkout','Other'=>'Other'); //eDebug(mktime(0,0,0,(strftime("%m")-1),1,strftime("%Y"))); $prev_month = strftime("%A, %d %B %Y", mktime(0, 0, 0, strftime("%m") - 1, 1, strftime("%Y"))); //eDebug(strftime("%A, %d %B %Y", mktime(0,0,0,(strftime("%m")-1),1,strftime("%Y")))); $now_date = strftime("%A, %d %B %Y"); $now_hour = strftime("%I"); $now_min = strftime("%M"); $now_ampm = strftime("%p"); assign_to_template(array('prev_month' => $prev_month, 'now_date' => $now_date, 'now_hour' => $now_hour, 'now_min' => $now_min, 'now_ampm' => $now_ampm)); assign_to_template(array('order_status' => $order_status)); assign_to_template(array('discounts' => $discounts)); //assign_to_template(array('states'=>$states)); assign_to_template(array('order_type' => $order_type)); assign_to_template(array('payment_methods' => $payment_methods)); }