public static function gI() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; }
/** * Recupera a instância do carrinho. * @return Cart */ public static function getInstance() { if ( self::$instance == null ) { self::$instance = new Cart(); } return self::$instance; }
public function before() { if ($this->request->is_ajax()) { $this->auto_render = FALSE; } $this->cart = Cart::instance(); parent::before(); }
public function action_index() { //$prd = array(array('id'=>1,'qty'=>1),array('id'=>4,'qty'=>3)); //$v = Cart::instance()->delete()->set($prd)->get(); //$v = Cart::instance()->delete()->set(1,2)->get(); //var_export($v); $this->template->content = View::factory('cart'); $this->template->cart = Cart::instance()->content; }
public function updateCart() { $_contentCart = Cart::instance('shopping')->content(); foreach ($_contentCart as $row) { $_rowId = $row->rowid; Cart::instance('shopping')->update($_rowId, Input::get($_rowId)); } return Redirect::to('qlmbasket')->with('_strTitle', 'Shopping Cart')->with('_strBannerTitle', 'Shopping Cart')->with('_strBannerDesc', 'Shopping Cart')->with('_strBannerImage', 'asserts/images/SecondPage/mainpage_label.jpg')->with('_strFaceTitle', 'Shopping Cart'); }
/** * @return void */ public function testGetProductIdFromCart() { $worker = \App::make('App\\Droit\\Shop\\Order\\Worker\\OrderWorkerInterface'); \Cart::instance('newInstance'); \Cart::add(55, 'Uno', 1, '12', array('weight' => 155)); \Cart::add(55, 'Uno', 1, '12', array('weight' => 155)); \Cart::add(56, 'Duo', 1, '34', array('weight' => 25)); \Cart::add(57, 'tres', 1, '35', array('weight' => 125)); $result = $worker->productIdFromCart(); $this->assertEquals([55, 55, 56, 57], $result); }
public function createInvoice() { try { $_invoice = new Invoices(); $_invoice->firstName = Session::get('checkout.address')[0]['firstName']; $_invoice->lastName = Session::get('checkout.address')[0]['lastName']; $_invoice->companyname = Session::get('checkout.address')[0]['companyname']; $_invoice->email = Session::get('checkout.address')[0]['email']; $_invoice->country = Session::get('checkout.address')[0]['country']; $_invoice->state = Session::get('checkout.address')[0]['state']; $_invoice->street = Session::get('checkout.address')[0]['street']; $_invoice->zipcode = Session::get('checkout.address')[0]['zipcode']; $_invoice->telephone = Session::get('checkout.address')[0]['telephone']; $_invoice->comment = Session::get('checkout.address')[0]['comment']; $_invoice->invoiceCreater = Session::get('checkout.payment')[0]['payment']; $_invoice->invoiceCreatedDate = date("Y-m-d"); $_itemsCount = Cart::instance('shopping')->count(); $_contentCart = Cart::instance('shopping')->content(); $_contentTotal = Cart::instance('shopping')->total() + Cart::instance('shopping')->total() * 10 / 100; $_calculateinvoice = $this->getinvoicenumber(); $_invoice->invoice = $_calculateinvoice; $_invoice->save(); foreach ($_contentCart as $row) { $_resultData = DB::table('qlm_printerdetails')->where('detailId', $row->id)->get(); $_invoicedetails = new InvoiceDetails(); $_invoicedetails->product = $row->name; $_invoicedetails->quantity = $row->qty; $_invoicedetails->unitprice = $row->price; $_invoicedetails->gst = $row->price * 10 / 100; $_invoicedetails->total = $row->price * $row->qty + $row->price * $row->qty * 10 / 100; $_invoicedetails->invoice = $_calculateinvoice; $_invoicedetails->save(); } } catch (Exception $_ex) { Log::info("\$\$\$ --- Error: " . $_ex . " --- \$\$\$"); } }
function formatMoney($number, $fractional = false) { $number = sprintf('%.2f', $number); while (true) { $replaced = preg_replace('/(-?\\d+)(\\d\\d\\d)/', '$1,$2', $number); if ($replaced != $number) { $number = $replaced; } else { break; } } return $number; } $_itemsCount = Cart::instance('shopping')->count(); $_contentCart = Cart::instance('shopping')->content(); $_contentTotal = Cart::instance('shopping')->total() + Cart::instance('shopping')->total() * 10 / 100; ?> </td> </tr> <tr> </tr> </table> </td> </tr> </table> <table style="border-width: 1px;border-color: #f5f5f5;border-collapse: collapse;"> <tr>
public function getPaymentStatus() { try { // Get the payment ID before session clear $payment_id = Session::get('paypal_payment_id'); // clear the session payment ID Session::forget('paypal_payment_id'); if (empty(Input::get('PayerID')) || empty(Input::get('token'))) { return View::make('pages.shoppingcart')->with('error', 'Payment failed'); } $payment = Payment::get($payment_id, $this->_api_context); // PaymentExecution object includes information necessary // to execute a PayPal account payment. // The payer_id is added to the request query parameters // when the user is redirected from paypal back to your site $execution = new PaymentExecution(); $execution->setPayerId(Input::get('PayerID')); //Execute the payment $result = $payment->execute($execution, $this->_api_context); if ($result->getState() == 'approved') { // payment made Mail::send('emails.qlm.cashondelivery', ['firstName' => Session::get('checkout.address')[0]['firstName'], 'lastName' => Session::get('checkout.address')[0]['lastName'], 'companyname' => Session::get('checkout.address')[0]['companyname'], 'email' => Session::get('checkout.address')[0]['email'], 'country' => Session::get('checkout.address')[0]['country'], 'state' => Session::get('checkout.address')[0]['state'], 'street' => Session::get('checkout.address')[0]['street'], 'zipcode' => Session::get('checkout.address')[0]['zipcode'], 'telephone' => Session::get('checkout.address')[0]['telephone'], 'comment' => Session::get('checkout.address')[0]['comment']], function ($message) { $message->to('*****@*****.**')->cc(Session::get('checkout.address')[0]['email'], '*****@*****.**')->bcc('*****@*****.**')->bcc('*****@*****.**')->subject('QLM Label Makers - Order from Shopping Cart(Paypal)'); // $message->attach($pathToFile); }); Cart::instance('shopping')->destroy(); Session::flush(); return View::make('pages.shoppingcart')->with('success', 'Payment success - Please receive order confirmation via email.'); } return View::make('pages.shoppingcart')->with('error', 'This transaction cannot be completed - Please check your card balance on Paypal or Contact Us'); } catch (Exception $ex) { return View::make('pages.shoppingcart')->with('error', 'This transaction cannot be completed - Please check your card balance on Paypal or Contact Us'); } }
<?php echo "order placed successfully"; Cart::instance('shopping')->destroy();
static function getInstance() { return self::$instance === null ? self::$instance = new self() : self::$instance; }
public function postPayment() { $payer = new Payer(); $payer->setPaymentMethod('paypal'); //==================== LIST ITEMS IN SHOPPING CART ========= // $_contentCart = Cart::instance('shopping')->content(); $_itemsCount = Cart::instance('shopping')->count(); $_arryItems = array(); $_i = 0; foreach ($_contentCart as $row) { if ($_i < $_itemsCount) { $item = new Item(); $item->setName($row->name)->setDescription($row->name)->setCurrency('USD')->setQuantity((double) $row->qty)->setTax((double) ($row->price * 10) / 100)->setPrice((double) $row->price); //$435.00 $_arryItems[$_i] = $item; $_i++; } } $item_list = new ItemList(); $item_list->setItems(array($_arryItems)); // add item to list $item_list = new ItemList(); $item_list->setItems($_arryItems); //==================== LIST ITEMS IN SHOPPING CART ========= // $details = new Details(); $details->setShipping("0")->setTax((string) (Cart::instance('shopping')->total() * 10) / 100)->setSubtotal((string) Cart::instance('shopping')->total()); $amount = new Amount(); $amount->setCurrency("USD")->setTotal((string) Cart::instance('shopping')->total() + Cart::instance('shopping')->total() * 10 / 100)->setDetails($details); // ### Transaction // A transaction defines the contract of a // payment - what is the payment for and who // is fulfilling it. Transaction is created with // a `Payee` and `Amount` types $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description'); $redirect_urls = new RedirectUrls(); $redirect_urls->setReturnUrl(URL::route('payment.status'))->setCancelUrl(URL::route('payment.status')); $payment = new Payment(); $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction)); try { $payment->create($this->_api_context); } catch (PayPal\Exception\PayPalConnectionException $ex) { echo $ex->getCode(); // Prints the Error Code echo $ex->getData(); // Prints the detailed error message die($ex); } catch (Exception $ex) { die($ex); } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirect_url = $link->getHref(); break; } } // add payment ID to session Session::put('paypal_payment_id', $payment->getId()); if (isset($redirect_url)) { // redirect to paypal return Redirect::away($redirect_url); } return View::make('pages.home'); }
/** * @return void */ public function testCalculPriceWithFirstAndSecondCoupon() { $worker = \App::make('App\\Droit\\Shop\\Cart\\Worker\\CartWorkerInterface'); $oneproduct = factory(App\Droit\Shop\Product\Entities\Product::class)->make(); $onecoupon = factory(App\Droit\Shop\Coupon\Entities\Coupon::class, 'one')->make(); \Cart::instance('newInstance'); // Has to match the factory product \Cart::add(100, 'Dos', 1, '10.00', array('weight' => 600)); $this->coupon->shouldReceive('findByTitle')->once()->andReturn($onecoupon); $this->product->shouldReceive('find')->twice()->andReturn($oneproduct); $worker->setCoupon($onecoupon->title)->applyCoupon(); // Product price => 10.00 // Coupon for product value 10% $this->assertEquals(9, \Cart::total()); // Add free shipping later for example via admin $this->withSession(['noShipping']); $worker->setShipping(); $this->assertEquals(0, $worker->orderShipping->price); }
public function getCartSumm() { $locale = Limb::toolkit()->getLocale(); return number_format(Cart::instance()->getTotalSumm(), $locale->fract_digits, $locale->decimal_symbol, $locale->thousand_separator); }
function testInstance() { $this->assertTrue(Cart::instance(10) === Cart::instance(10)); }
</li> <li> <a href="requestquote">request a quote</a> </li> <li> <a href="member-login" target="_blank">sign in</a> </li> <li> <a href="faq">help</a> </li> <li class="last"> <a href="qlmbasket">my cart<?php if (Cart::instance('shopping')->count() > 0) { ?> (<?php echo Cart::instance('shopping')->count(); ?> )<?php } ?> </a> </li> </ul> </div> <!-- --------------------------------- logo : 4 items --------------------------------- --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#qlm-tablet"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
Route::post('qlmbasket/updatetocart', function () { if (Cart::instance('tempshopping')->count() > 0) { $_tempcontentCart = Cart::instance('tempshopping')->content(); $_contentCart = Cart::instance('shopping')->content(); foreach ($_contentCart as $row) { foreach ($_tempcontentCart as $temprow) { if ($row->id == $temprow->id) { Cart::instance('shopping')->update($row->rowid, $temprow->qty); break; } } } } Cart::instance('tempshopping')->destroy; //if success return Response::json(array('success' => true, 'message' => 'update all to cart successfully', 'count' => Cart::instance('shopping')->count())); }); Route::post('sendEmailContactUs', 'SendEmailController@contactUs'); Route::post('sendEmailRequestaQuote', 'SendEmailController@requestaQuote'); Route::post('cashondelivery', 'SendEmailController@cashondelivery'); Route::post('search', 'BaseController@search'); Route::post('home/signup_email/{_email}', function ($_email) { try { $_count = DB::table('qlm_followemails')->where('email', $_email)->count(); if ($_count == 0) { DB::table('qlm_followemails')->insert(array('email' => $_email, 'createdDate' => date('Y-m-d'))); //if success return Response::json(array('success' => true, 'message' => 'Thank you for sign up your email!')); } else { //if fail return Response::json(array('error' => true, 'message' => 'This email is already registered!'));
public function action_index() { $this->template->cart = Cart::instance()->content; }
/** * @expectedException Gloudemans\Shoppingcart\Exceptions\ShoppingcartInstanceException */ public function testShoppingcartInstanceException() { Cart::instance(); }