Example #1
0
 function post()
 {
     foreach (json_decode(Input::get('json')) as $i) {
         $c = StoreProduct::find($i->id);
         $c->sort = $i->sort;
         $c->save();
     }
     Session::flash('Success Message', 'Saved sort order');
     return \Redirect::to("/admin/store-products");
 }
Example #2
0
 function complete($checkoutDetails)
 {
     Session::flash('success', 'Your order has been successfully completed and paid. You will receive an invoice at the email you provided and your order will be prepared and (if you selected) shipped as soon as possible.');
     Log::info('order completed: ' . json_encode($checkoutDetails, JSON_PRETTY_PRINT) . json_encode(Cart::instance('main')->content(), JSON_PRETTY_PRINT) . json_encode(Session::get('shipping'), JSON_PRETTY_PRINT));
     Cart::instance('complete')->destroy();
     foreach (Cart::instance('main')->content()->toArray() as $key => $val) {
         Cart::instance('complete')->add($val);
     }
     Cart::instance('main')->destroy();
     Session::put('shipping-complete', Session::get('shipping'));
     Session::remove('shipping');
     $order = new StoreOrder();
     $order->fields = json_encode($checkoutDetails, JSON_PRETTY_PRINT);
     $order->email = @$checkoutDetails["EMAIL"] ?: '';
     $order->payer_id = @$checkoutDetails["PAYERID"] ?: '';
     $order->payer_status = @$checkoutDetails["PAYERSTATUS"] ?: '';
     $order->first_name = @$checkoutDetails["FIRSTNAME"] ?: '';
     $order->last_name = @$checkoutDetails["LASTNAME"] ?: '';
     $order->country_code = @$checkoutDetails["COUNTRYCODE"] ?: '';
     $order->ship_to_name = @$checkoutDetails["SHIPTONAME"] ?: '';
     $order->ship_to_street = @$checkoutDetails["SHIPTOSTREET"] ?: '';
     $order->ship_to_city = @$checkoutDetails["SHIPTOCITY"] ?: '';
     $order->ship_to_state = @$checkoutDetails["SHIPTOSTATE"] ?: '';
     $order->ship_to_zip = @$checkoutDetails["SHIPTOZIP"] ?: '';
     $order->ship_to_country = @$checkoutDetails["SHIPTOCOUNTRYNAME"] ?: '';
     $order->currecncy_code = @$checkoutDetails["CURRENCYCODE"] ?: '';
     $order->note = @$checkoutDetails["PAYMENTREQUEST_0_NOTETEXT"] ?: '';
     $order->shipping = Session::get('shipping-complete') ?: null;
     $order->total = Cart::instance('complete')->total() + Session::get('shipping-complete');
     $order->completed = 1;
     $order->save();
     foreach (Cart::instance('complete')->content() as $row) {
         $product = new StoreOrderProduct();
         $product->store_order_id = $order->id;
         $product->product = StoreProduct::find($row["options"]["product"])->name;
         $product->select = isset($row["options"]["select"]) && StoreSelectItem::find($row["options"]["select"]) !== null ? StoreSelectItem::find($row["options"]["select"])->name : '';
         $product->type_price = isset($row["options"]["price"]) && StoreTypePrice::find($row["options"]["price"]) != null ? StoreTypePrice::find($row["options"]["price"])->name : '';
         $product->quantity = $row["qty"];
         $product->price = $row["subtotal"];
         $product->save();
     }
     if (Input::has('return')) {
         return Redirect::to(Input::get('return'));
     } else {
         return Redirect::to(Config::get('punto-cms.complete-url'));
     }
 }