当前位置: 首页>>代码示例>>PHP>>正文


PHP Cart::getTotal方法代码示例

本文整理汇总了PHP中Cart::getTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::getTotal方法的具体用法?PHP Cart::getTotal怎么用?PHP Cart::getTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cart的用法示例。


在下文中一共展示了Cart::getTotal方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postCheckout

 public function postCheckout()
 {
     $payer = PayPal::Payer();
     $payer->setPaymentMethod('paypal');
     $amount = PayPal::Amount();
     $amount->setCurrency('USD');
     $amount->setTotal(intval(\Cart::getTotal()) / 20);
     // This is the simple way,
     // you can alternatively describe everything in the order separately;
     // Reference the PayPal PHP REST SDK for details.
     $transaction = PayPal::Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription('Thanh Toán Mua Hàng Từ Couponia?');
     $redirectUrls = PayPal::RedirectUrls();
     $redirectUrls->setReturnUrl(\Redirect::getUrlGenerator()->route('paypal-done'));
     $redirectUrls->setCancelUrl(\Redirect::getUrlGenerator()->route('paypal'));
     $payment = PayPal::Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions(array($transaction));
     $response = $payment->create($this->_apiContext);
     $redirectUrl = $response->links[1]->href;
     return \Redirect::to($redirectUrl);
 }
开发者ID:nhatkhoa,项目名称:GroupBuy,代码行数:25,代码来源:PaymentController.php

示例2: loadFromCart

 public function loadFromCart(Cart $cart)
 {
     $shopInfo = new ShopInfo($cart->module_srl);
     $this->cart_srl = $cart->cart_srl;
     $this->module_srl = $cart->module_srl;
     $this->member_srl = $cart->member_srl;
     $this->client_name = $cart->getBillingAddress()->firstname . ' ' . $cart->getBillingAddress()->lastname;
     $this->client_email = $cart->getBillingAddress()->email;
     $this->client_company = $cart->getBillingAddress()->company;
     $this->billing_address = (string) $cart->getBillingAddress();
     $this->shipping_address = (string) $cart->getShippingAddress();
     $this->payment_method = $cart->getPaymentMethodName();
     $this->shipping_method = $cart->getShippingMethodName();
     $this->shipping_variant = $cart->getShippingMethodVariant();
     $this->shipping_cost = $cart->getShippingCost();
     $this->total = $cart->getTotal(true);
     $this->vat = $shopInfo->getVAT() ? $shopInfo->getVAT() : 0;
     $this->order_status = Order::ORDER_STATUS_PENDING;
     $this->ip = $_SERVER['REMOTE_ADDR'];
     $this->currency = $shopInfo->getCurrency();
     if ($discount = $cart->getDiscount()) {
         $this->discount_min_order = $discount->getMinValueForDiscount();
         $this->discount_type = $shopInfo->getShopDiscountType();
         $this->discount_amount = $discount->getReductionValue();
         $this->discount_tax_phase = $discount->calculateBeforeApplyingVAT() ? 'pre_taxes' : 'post_taxes';
         $this->discount_reduction_value = $discount->getReductionValue();
     }
     if ($coupon = $cart->getCoupon()) {
         $this->coupon_discount_value = $cart->getCouponDiscount();
     }
 }
开发者ID:haegyung,项目名称:xe-module-shop,代码行数:31,代码来源:Order.php

示例3: createUserInterface

 /**
  * @see		ApplicationView::createUserInterface()
  */
 protected function createUserInterface()
 {
     parent::createUserInterface();
     $this->addStyle('/css/cart.css');
     $resourceBundle = Application::getInstance()->getBundle();
     $products = $this->cart->getProducts();
     if (count($products) == 0) {
         $this->contentPanel->addChild(new Heading(2))->addChild(new Text($resourceBundle->getString('CART_NO_PRODUCT')));
     } else {
         $this->contentPanel->addChild(new CartList())->setProductList($products);
         $totalParagraph = $this->contentPanel->addChild(new Paragraph())->addStyle('cart-total');
         //Total do carrinho
         $totalParagraph->addChild(new Strong())->addChild(new Text($resourceBundle->getString('CART_TOTAL')));
         $totalParagraph->addChild(new Span())->addChild(new Text(money_format($resourceBundle->getString('MONEY_FORMAT'), $this->cart->getTotal())));
         //Botão de checkout
         $totalParagraph->addChild(new Anchor('/?c=cart&a=checkout'))->addStyle('checkout')->addChild(new Text($resourceBundle->getString('CART_CHECKOUT')));
     }
 }
开发者ID:rcastardo,项目名称:mvc-na-pratica,代码行数:21,代码来源:CartView.php

示例4: add_some_extra

                $unit = 'Rupees ';
            };
        
        array_walk($this->products, $callback);
        return $unit .round($total, 2);
    }
}

$my_cart = new Cart;
// Add some items to the cart
$my_cart->add('butter', 1);
$my_cart->add('milk', 3);
$my_cart->add('eggs', 6);
$my_cart->getArray(); //Array ( [butter] => 1 [milk] => 3 [eggs] => 6 ) 
// Print the total with a 5% sales tax.
print $my_cart->getTotal(0.05) . "\n";
// The result is 54.29
?>
<?php
#Example #2 Passing function parameters by reference
function add_some_extra(&$string)
{
    $string .= 'and something extra.'. "\n\n";
}
$str = "\n\n" . 'This is a string, ';
add_some_extra($str);
echo $str;    // outputs 'This is a string, and something extra.'
//if passed not by reference it will outputs 'This is a string' only.
?>
<?php
#Example #2 Passing function parameters by reference
开发者ID:jestintab,项目名称:zendphp,代码行数:31,代码来源:functions_more.php

示例5: doAddToCart

 /**
  * cart model to maitain items array
  * in cart befor it is been posted to 
  * the purchases table
  */
 public function doAddToCart()
 {
     $basket = new Cart();
     $mcart = "";
     $basket->addItem($_POST['ppid'], $_POST['ppname'], $_POST['pcatname'], $_POST['pqty'], $_POST['pprice']);
     $myItems = $basket->getContents();
     // the basket get arrays of items in the cart
     $quantity = $_POST['pqty'];
     $subTotal = $basket->getTotal();
     // the basket gets the total of the items as subtotal
     $vat = 0.05 * $subTotal;
     // calculates the vat
     $total = $subTotal + $vat;
     $mcart .= "<table id='minicart-a' summary='Employee Pay Sheet'>\n    <thead>\n    \t<tr>\n            <th width='10%' scope='col'>ItemID</th>\n        \t<th width='35%' scope='col' >Description</th>\n            <th width='20%' scope='col'>Qty</th>\n            <th width='10%' scope='col'>Cost</th>\n            <th width='10%' scope='col'>Total</th>\n            \n        </tr>\n    </thead>\n    <tbody>";
     //print_r($item['itemName']);
     $qt = 0;
     foreach ($myItems as $item) {
         $myproduct = Items::find_by_id($item['itemId']);
         //print_r($myproduct);
         $mcart .= "<tr>\n              \n              <td>" . $item['itemName'] . "</td>\n              <td>" . $myproduct->item_description . "</td>\n              <td><span>\n                <input type='text' name='qty' id='qty" . $qt . "' value='" . $item['itemQuantity'] . "' style='width:40px; padding:2px; height:36px; text-align:center; '  />\n              </span>&nbsp;&nbsp;<span><a href='#' class='modifyqty' prodid='" . $item['itemId'] . "' prodqty='" . $item['itemQuantity'] . "'  tprice='" . $item['itemPrice'] . "' count ='" . $qt . "' ><img src='public/icons/Refresh16.png' width='18' height='18' /></a></span>&nbsp;&nbsp;<span><a href='#' class='deleteitem' prodid='" . $item['itemId'] . "'  ><img src='public/icons/Delete16.png' width='18' height='18' /></a></span></td>\n              <td>&#8358;" . number_format($item['itemPrice'], 2, '.', ',') . "</td>\n              <td>&#8358;" . number_format($item['itemTotal'], 2, '.', ',') . "</td>\n            </tr>";
         $qt++;
     }
     /**
      * foreach($myItems as $item){
      *     	$mcart .="<tr>
      *         	<td>".$item['itemQuantity']."</td>
      *             <td>".$item['itemName']."</td>
      *             <td>&#8358;".$item['itemName']."</td>
      *             <td>".number_format($item['itemPrice'],2,'.',',')."</td>
      *             <td><span class='bold'>&#8358;".number_format($item['itemTotal'],2,'.',',')."</span></td>
      *             <td><span class='bold'>x</span></td>
      *         </tr>
      *         
      *         ";
      * 	}
      */
     $mcart .= "<tr>\n        \t<td>&nbsp;</td>\n            <td>&nbsp;</td>\n            <td>&nbsp;</td>\n            <td>&nbsp;</td>\n            <td>&nbsp;</td>\n        </tr>       \n\t    <tr>\n          <td>&nbsp;</td>\n          <td colspan='3' align='right'><h3 class='black'>SubTotal:</h3></td>\n          <td colspan='3' align='right'><span class='bold'>&#8358;" . number_format($subTotal, 2, '.', ',') . "</span></td>\n        </tr>\n        <tr>\n          <td>&nbsp;</td>\n          <td colspan='3' align='right'><h3 class='black'>VAT(5%):</h3></td>\n          <td colspan='3' align='right'><span class='bold'>&#8358;" . number_format($vat, 2, '.', ',') . "</span></td>\n        </tr>\n        <tr>\n          <td>&nbsp;</td>\n          <td colspan='3' align='right'><h3><span class='black'>Total:</span></h3></td>\n          <td colspan='3' align='right'><div class='divider'></div><h3 class='bold'>&#8358;" . number_format($total, 2, '.', ',') . "</h3><div class='divider'></div><div class='divider'></div></td>\n        </tr>\n        <tr>\n        \t<td>&nbsp;</td>\n            <td colspan='3' align='right'><span style='margin:5px'><a href='#'>view cart</a></span></td>\n            <td colspan='3'><span style='margin:5px'><a href='#'>Check out</a></span></td>\n            </tr>\n    </tbody>\n</table>";
     print_r($mcart);
 }
开发者ID:runningjack,项目名称:RobertJohnson,代码行数:44,代码来源:stockin.php

示例6: postCheckout

 public function postCheckout(Request $request)
 {
     \DB::beginTransaction();
     $customer = Customer::create($request->all());
     $order = $customer->orders()->create(['quantity' => \Cart::getTotalQuantity(), 'total' => \Cart::getTotal(), 'shipped' => false]);
     foreach (\Cart::getContent() as $cart) {
         $order->details()->create(['deal_id' => $cart->id, 'quantity' => $cart->quantity, 'price' => $cart->price]);
     }
     $order->push();
     $customer->push();
     \DB::commit();
     \Cart::clear();
     return view('frontend.checkout.done')->with('categories', Category::all());
 }
开发者ID:nhatkhoa,项目名称:GroupBuy,代码行数:14,代码来源:MainController.php

示例7: getTotal

    {
        $this->p[$k] = (double) $p;
    }
    public function getTotal($tax)
    {
        $sum = 0;
        array_walk($this->p, function ($val) use($tax, &$sum) {
            $sum += $val * ($tax + 1.0);
        });
        return $sum;
    }
}
$cart = new Cart();
$cart->addProduct('apple', 10);
$cart->addProduct('rasberry', 45);
echo $cart->getTotal(0.196);
var_dump('------- static private-------');
$sum = function ($v) {
    return function () use($v) {
        return ++$v;
    };
};
$r = $sum(10);
echo $r();
$r = $sum(10);
echo $r();
var_dump('---------- Exemple de contexte global pour une variable PHP');
$val = 10;
function baz()
{
    $val = 11;
开发者ID:Antoine07,项目名称:Base-Objet,代码行数:31,代码来源:exos.php

示例8: action_credit

 public function action_credit()
 {
     if (!$this->check_logged()) {
         \Messages::error('You must be logged in if you want to continue with your order.');
         \Response::redirect(\Uri::create('order/checkout/address'));
     }
     if (!\Input::post()) {
         throw new \HttpNotFoundException();
     }
     if (\Input::post('order_type') == 'payment') {
         \Response::redirect(\Uri::create('order/checkout/payment'));
     }
     $credit_account = \Order\Model_Order::credit_account(null, \Cart::getTotal('price'));
     if (\Input::post('order_type') != 'credit') {
         \Messages::error('There was an error while trying to save your order.');
         \Response::redirect(\Input::referrer(\Uri::create('order/checkout/cost')));
     }
     if (!$credit_account['credit'] || $credit_account['over_limit']) {
         \Messages::error("You don't have permission for this action.");
         \Response::redirect(\Input::referrer(\Uri::create('order/checkout/cost')));
     }
     $user = \Sentry::user();
     if ($order = $this->save_order()) {
         $payment = \Payment\Model_Payment::forge();
         $payment->order_id = $order->id;
         $payment->total_price = $order->total_price;
         $payment->method = 'credit';
         $payment->status = 'ordered';
         $payment->status_detail = 'Credit Account';
         $payment->save();
         $this->autoresponder($user, $order);
         \Response::redirect(\Input::referrer(\Uri::create('order/checkout/complete/' . $order->id)));
     }
     \Messages::error('There was an error while trying to save your order.');
     \Response::redirect(\Input::referrer(\Uri::create('order/checkout/cost')));
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:36,代码来源:checkout+copy.php

示例9: action_credit

 public function action_credit()
 {
     if (!$this->check_logged()) {
         \Messages::error('You must be logged in if you want to continue with your order.');
         \Response::redirect(\Uri::create('order/checkout/address'));
     }
     if (!\Input::post()) {
         throw new \HttpNotFoundException();
     }
     if (\Input::post('order_type') == 'payment') {
         \Response::redirect(\Uri::create('order/checkout/payment'));
     }
     $credit_account = \Order\Model_Order::credit_account(null, \Cart::getTotal('price'));
     if (\Input::post('order_type') != 'credit') {
         \Messages::error('There was an error while trying to save your order.');
         \Response::redirect(\Input::referrer(\Uri::create('order/checkout/cost')));
     }
     if (!$credit_account['credit'] || $credit_account['over_limit']) {
         \Messages::error("You don't have permission for this action.");
         \Response::redirect(\Input::referrer(\Uri::create('order/checkout/cost')));
     }
     $items = \Cart::items();
     $user = \Sentry::user();
     if ($order = $this->save_order()) {
         $payment = \Payment\Model_Payment::find_one_by_order_id($order->id);
         if (!isset($payment)) {
             $payment = \Payment\Model_Payment::forge();
         }
         $total_price = $order->total_price ? $order->total_price + $order->shipping_price - $order->discount_amount : $order['total_price'] + $order['shipping_price'] - $order['discount_amount'];
         $payment->set(array('order_id' => $order->id, 'total_price' => $total_price, 'method' => 'credit', 'status' => 'ordered', 'status_detail' => 'Credit Account'));
         $payment->save();
         $this->autoresponder($user, $order);
         \Response::redirect(\Input::referrer(\Uri::create('order/checkout/complete/' . $order->id)));
     }
     \Messages::error('There was an error while trying to save your order.');
     \Response::redirect(\Input::referrer(\Uri::create('order/checkout/cost')));
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:37,代码来源:checkout.php

示例10: testCartTotal_WithUnavailableProducts

    /**
     * Test cart when a product becomes unavailable (deleted / out of stock)
     * after the user has already added it to the cart
     */
    public function testCartTotal_WithUnavailableProducts()
    {
        $module_srl = 107;
        $cart_srl = 774;
        $deleted_product_srl = 133;

        // Act: delete one product from xe_products but keep it in cart
        $product_repository = new ProductRepository();
        $args = new stdClass();
        $args->product_srl = $deleted_product_srl;
        $product_repository->deleteProduct($args);

        $cart = new Cart($cart_srl);

        // Assert
        // 1. Check that cart has expected products
        $this->assertEquals(1, count($cart->getProducts(NULL, TRUE))); // When $onlyAvailable is true, count just availablel products
        $this->assertEquals(2, count($cart->getProducts())); // Default, , show all products

        // 3. Check that item total is correct
        $this->assertEquals(29.99, $cart->getItemTotal()); // Count just available products

        // 4. Check global total is correct (includes shipping +10)
        $this->assertEquals(39.99, $cart->getTotal(), '', 0.01); // Count just available products
    }
开发者ID:haegyung,项目名称:xe-module-shop,代码行数:29,代码来源:CartTest.php

示例11: setPromo

<?php

namespace CoR2;

$promo = Promo::init();
$cart = new Cart();
$cart->setPromo($promo);
$cart->add('A0001', 1);
$cart->add('A0002', 2);
$cart->add('B0001', 1);
$cart->add('B0002', 2);
$cart->add('C0001', 1);
$cart->add('C0002', 2);
$cart->calculate();
$cart->listAll();
echo $cart->getTotal(), "\n";
class Cart
{
    protected static $_priceTable = ['A0001' => 100, 'A0002' => 150, 'B0001' => 300, 'B0002' => 200, 'C0001' => 200, 'C0002' => 200];
    protected $_total = 0;
    protected $_items = [];
    protected $_promo = null;
    public function setPromo(Promo $promo)
    {
        $this->_promo = $promo;
    }
    public function add($sn, $quantity)
    {
        $price = static::$_priceTable[$sn];
        $price = $this->_promo->calculate($sn, $price);
        $this->_items[$sn] = [$price, $quantity];
开发者ID:YidaChen,项目名称:tutorial-php-advenced,代码行数:31,代码来源:02.php

示例12: notify

    /**
     * Handles all IPN notifications from Paypal
     */
    public function notify($cart)
    {
        // 1. Retrieve all POST data received and post back to paypal, to make sure
        // the request sender is not fake

        // Do not retrieve data with Context::getRequestVars() because it skips empty values
        // causing the Paypal validation to fail
        $args = $_POST;
        if(__DEBUG__)
        {
            ShopLogger::log("Received IPN Notification: " . http_build_query($args));
        }

        $response = $this->postDataBackToPaypalToValidateSenderIdentity($args);

        if($response->isVerified())
        {
            ShopLogger::log("Successfully validated IPN data");

            $payment_info = $this->getIPNPaymentInfo($args);

            if(!$payment_info->isRelatedToCartPayment())
                return;

            // 2. If the source of the POST is correct, we now need to check that data is also valid
            if(!$order = $this->orderCreatedForThisTransaction($payment_info->txn_id))
            {
                // check that receiver_email is your Primary PayPal email
                if(!$payment_info->paymentReceiverIsMe($this->business_account))
                {
                    ShopLogger::log("Possible fraud - invalid receiver email: " . $payment_info->receiver_email);
                    $this->markTransactionAsFailedInUserCart(
                        $payment_info->cart_srl,
                        $payment_info->txn_id,
                        "There was a problem processing your payment. Your order could not be completed."
                    );
                    return;
                }

                // check the payment_status is Completed
                if(!$payment_info->paymentIsComplete())
                {
                    ShopLogger::log("Payment is not completed. Payment status [" . $payment_info->payment_status. "] received");
                    $this->markTransactionAsFailedInUserCart(
                        $payment_info->cart_srl,
                        $payment_info->txn_id,
                        "Your payment was not completed. Your order was not created."
                    );
                    return;
                }

                $cart = new Cart($payment_info->cart_srl);
                if(!$payment_info->paymentIsForTheCorrectAmount($cart->getTotal(), $cart->getCurrency()))
                {
                    ShopLogger::log("Invalid payment. " . PHP_EOL
                        . "Payment amount [" . $payment_info->payment_amount . "] instead of " . $cart->getTotal() . PHP_EOL
                        . "Payment currency [" . $payment_info->payment_currency . "] instead of " . $cart->getCurrency()
                    );
                    $this->markTransactionAsFailedInUserCart(
                        $payment_info->cart_srl,
                        $payment_info->txn_id,
                        "Your payment was invalid. Your order was not created."
                    );
                    return;
                }

                // 3. If the source of the POST is correct, we can now use the data to create an order
                // based on the message received
                $this->createNewOrderAndDeleteExistingCart($cart, $payment_info->txn_id);
            }
        }
        else
        {
            ShopLogger::log("Invalid IPN data received: " . $response);
        }

    }
开发者ID:haegyung,项目名称:xe-module-shop,代码行数:80,代码来源:PaypalPaymentsStandard.php

示例13: processPayment

	/**
	 * Process the payment
	 *
	 * @param Cart $cart
	 * @param      $error_message
	 * @return bool|mixed
	 */
	public function processPayment(Cart $cart, &$error_message)
    {
		$cc_number = Context::get('cc_number');
		$cc_exp_month = Context::get('cc_exp_month');
		$cc_exp_year = Context::get('cc_exp_year');
		$cc_cvv = Context::get('cc_cvv');

		// Unset credit card info so that XE won't put it in session
		Context::set('cc_number', NULL);
		Context::set('cc_exp_month', NULL);
		Context::set('cc_exp_year', NULL);
		Context::set('cc_cvv', NULL);

		if(!$cc_number)
		{
			$error_message = "Please enter you credit card number"; return FALSE;
		}
		if(!$cc_exp_month || !$cc_exp_year)
		{
			$error_message = "Please enter you credit card expiration date"; return FALSE;
		}
		if(!$cc_cvv)
		{
			$error_message = "Please enter you credit card verification number"; return FALSE;
		}

		$cc_number = str_replace(array(' ', '-'), '', $cc_number);
		if (!preg_match ('/^4[0-9]{12}(?:[0-9]{3})?$/', $cc_number) // Visa
			&& !preg_match ('/^5[1-5][0-9]{14}$/', $cc_number) // MasterCard
			&& !preg_match ('/^3[47][0-9]{13}$/', $cc_number) // American Express
			&& !preg_match ('/^6(?:011|5[0-9]{2})[0-9]{12}$/', $cc_number) //Discover
		){
			$error_message = 'Please enter your credit card number!';
		}

		$cc_exp = sprintf('%02d%d', $cc_exp_month, $cc_exp_year);

        $transaction = new AuthorizeNetAim($this->api_login_id, $this->transaction_key);
		// 1. Set payment info
		$transaction->amount = $cart->getTotal();
        $transaction->card_num = $cc_number;
        $transaction->exp_date = $cc_exp;
		$transaction->invoice_num = $cart->cart_srl;

		// 2. Set billing address info
		$transaction->first_name = $cart->getCustomerFirstname();
		$transaction->last_name = $cart->getCustomerLastname();
		$transaction->company = $cart->getBillingAddress()->company;
		$transaction->address = $cart->getBillingAddress()->address;
		$transaction->city = $cart->getBillingAddress()->city;
		$transaction->zip = $cart->getBillingAddress()->postal_code;
		$transaction->country = $cart->getBillingAddress()->country;
		$transaction->email = $cart->getBillingAddress()->email;

		// 3. Set shipping address info
		$transaction->ship_to_first_name = $cart->getShippingAddress()->firstname;
		$transaction->ship_to_last_name = $cart->getShippingAddress()->lastname;
		$transaction->ship_to_company = $cart->getShippingAddress()->company;
		$transaction->ship_to_address = $cart->getShippingAddress()->address;
		$transaction->ship_to_city = $cart->getShippingAddress()->city;
		$transaction->ship_to_zip = $cart->getShippingAddress()->postal_code;
		$transaction->ship_to_country = $cart->getShippingAddress()->country;

        $response = $transaction->authorizeAndCapture();

        if ($response->approved) {
            return TRUE;
        } else {
			ShopLogger::log("Authorize.NET transaction failed: " . print_r($response, TRUE));
            $error_message = "There was a problem with charging your credit card; Please try again or try a different payment method";
            return FALSE;
        }
    }
开发者ID:haegyung,项目名称:xe-module-shop,代码行数:80,代码来源:Authorize.php

示例14: Cart

    function _checkout_step_2($values = null, $errors = null)
    {
        $cart = new Cart('shopping_cart');
        //get promo discount
        $discount_text = '';
        if (isset($_SESSION['order']['promo_code'])) {
            $discount = $cart->getDiscount($_SESSION['order']['promo_code']);
            if ($discount > 0) {
                $discount_text = '...including -$' . number_format($discount, 2) . ' discount.';
            }
        } else {
            $discount = 0;
        }
        //get total
        $total = number_format($cart->getTotal() + $cart->getTax() - $discount, 2);
        //get taxes
        $taxes = number_format($cart->getTax(), 2);
        $output = '	
		<div id="checkout">
		<div id="summary"><h3 class="price">$' . $total . '</h3>
		<i>...including FREE shipping.<br />
		...including $' . $taxes . ' taxes.<br />
		' . $discount_text . '</i></div>
		<p id="step">step 2 of 2</p>
		<form action="" method="post">
		<input type="hidden" name="step" value="2" />
		
		<h3>Shipping Information</h3>
		
		<p>Shipping is <strong>FREE</strong></p>
		
		<h3>Payment Information</h3>
		
		<table border="0" id="checkout">
			<tr>
				<td class="label" nowrap="1"><label for="cc_name">Name:</label></td>
				<td class="field"><input type="text" name="order[cc_name]" size="30" value="' . htmlentities($values['order']['cc_name']) . '" /> ' . $this->_field_error($errors, 'cc_name') . '</td>
			</tr>
			<tr>
				<td class="label" nowrap="1"><label for="cc_type">Card Type:</label></td>
				<td class="field">
					<select name="order[cc_type]">
						<option value="">-- Select Card --</option>	
						' . str_replace('value="' . $values['order']['cc_type'] . '"', 'value="' . $values['order']['cc_type'] . '" selected="selected"', $this->_cc_type_options()) . '
					</select> ' . $this->_field_error($errors, 'cc_type') . '
				</td>
			</tr>
			<tr>
				<td class="label" nowrap="1"><label for="cc_number">Card Number:</label></td>
				<td class="field"><input type="text" name="order[cc_number]" size="30" value="' . htmlentities($values['order']['cc_number']) . '" /> ' . $this->_field_error($errors, 'cc_number') . '</td>
			</tr>
			<tr>
				<td class="label" nowrap="1"><label for="cc_cvv">CVV:</label></td>
				<td class="field"><input type="text" name="order[cc_cvv]" size="4" value="' . htmlentities($values['order']['cc_cvv']) . '" /> ' . $this->_field_error($errors, 'cc_cvv') . ' <a href="javascript:void(0);" onclick="$(\'cvv\').toggle();">what is this?</a>
				
				<div id="cvv" style="display: none;">
					<p>For MasterCard or Visa, it\'s the last three digits in the signature area on the back of your card. For American Express, it\'s the four digits on the front of the card.
				</div>
				
				</td>
			</tr>
			<tr>
				<td class="label" nowrap="1"><label for="cc_exp_month">Expiration Date:</label></td>
				<td class="field">
					<select name="order[cc_exp_month]">
						<option value="">-- Month --</option>
						' . str_replace('value="' . $values['order']['cc_exp_month'] . '"', 'value="' . $values['order']['cc_exp_month'] . '" selected="selected"', $this->_cc_exp_month_options()) . '
					</select> ' . $this->_field_error($errors, 'cc_exp_month') . '
			
					<select name="order[cc_exp_year]">
						<option value="">-- Year --</option>	
						' . str_replace('value="' . $values['order']['cc_exp_year'] . '"', 'value="' . $values['order']['cc_exp_year'] . '" selected="selected"', $this->_cc_exp_year_options()) . '
					</select> ' . $this->_field_error($errors, 'cc_exp_year') . '
				</td>
			</tr>
		</table>
		
		<hr />
		
		<p>
			<input class="button" type="submit" value="Complete my purchase" /> or 
			<a href="/products/types">cancel, and continue shopping</a>
		</p>
		
		</form>
		</div>
		';
        return $output;
    }
开发者ID:shuhrat,项目名称:frog_ecommerce,代码行数:89,代码来源:EcommerceController.php


注:本文中的Cart::getTotal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。