本文整理汇总了PHP中Cart::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::add方法的具体用法?PHP Cart::add怎么用?PHP Cart::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postAddtocart
public function postAddtocart()
{
$product = Product::find(Input::get('id'));
$quantity = Input::get('quantity');
Cart::add(array('id' => $product->id, 'name' => $product->title, 'price' => $product->price, 'qty' => $quantity, 'image' => $product->image));
return Redirect::to('store/cart');
}
示例2: addToCart
public function addToCart($deal_id)
{
$amount = 1;
if ($amount <= 0) {
throw new BadRequestHttpException('QUALITY_MUST_GREATER_THAN_0');
}
$deal = Deal::find($deal_id);
if ($deal == null) {
throw new NotFoundException('NOT_FOUND');
}
if ($deal->stock < $amount) {
throw new BadRequestHttpException('OUT_OF_STOCK');
}
if ($deal->time_expired < Carbon::now()) {
throw new BadRequestHttpException('EXPIRED');
}
// --- Check if deal is existed in cart
$deal_cart = \Cart::get($deal_id);
if ($deal_cart == null) {
\Cart::add(['id' => $deal->id, 'name' => $deal->name, 'quantity' => $amount, 'price' => $deal->deal_price, 'attributes' => ['list_price' => $deal->list_price, 'time_expired' => $deal->time_expired, 'thumb' => $deal->getThumb()]]);
} else {
\Cart::update($deal_id, ['quantity' => $amount]);
}
return redirect('/gio-hang');
}
示例3: add
public function add(){
if(IS_AJAX ===false) throw new Exception('请求错误');
$result = array();
if(is_null($this->uid)){
$data = array(
'id' => $this->_get('gid','intval'),
'name' =>'',
'num' =>1,
'price' =>0
);
Cart::add($data);
$total = count($_SESSION['cart']['goods']);
$result = array('status'=>true,'total'=>$total);
}else{
$data = array();
$data['goods_id'] = $this->_get('gid','intval');
$data['user_id'] = $this->uid;
$data['goods_num'] = 1;
$result = $this->checkAdd($data);
if($result){
$db = K('cart');
$where = array('user_id'=>$data['user_id']);
$total = $db->countCart($where);
$result = array('status'=>true,'total'=>$total);
}
}
exit(json_encode($result));
}
示例4: addRoomDetailsToCart
public function addRoomDetailsToCart()
{
$addToCartDetailsOfRoom = Input::all();
Cart::add(array('id' => $addToCartDetailsOfRoom['roomIDBook'], 'name' => $addToCartDetailsOfRoom['branchBook'], 'qty' => 1, 'price' => $addToCartDetailsOfRoom['priceBook']));
//Cart::destroy();
$addedToCart = true;
return Response::json($addedToCart);
}
示例5: addData
public function addData($data, $add, $type)
{
$delivery = array();
$cart = new Cart();
if ($data->{$type}->currency == 'RUR') {
$currency_id = Currency::getIdByIsoCode('RUB');
} else {
$currency_id = Currency::getIdByIsoCode($data->cart->currency);
}
$def_currency = Configuration::get('PS_CURRENCY_DEFAULT');
$this->context->cookie->id_currency = $def_currency != $currency_id ? $currency_id : $def_currency;
$this->context->cookie->write();
$this->context->currency = new Currency($this->context->cookie->id_currency);
$cart->id_lang = (int) $this->context->cookie->id_lang;
$cart->id_currency = (int) $this->context->cookie->id_currency;
$cart->id_guest = (int) $this->context->cookie->id_guest;
$cart->add();
$this->context->cookie->id_cart = (int) $cart->id;
$this->context->cookie->write();
$buyer = isset($data->{$type}->buyer) ? $data->{$type}->buyer : '';
$b = array();
if ($add) {
$delivery = isset($data->{$type}->delivery->address) ? $data->{$type}->delivery->address : new stdClass();
$street = isset($delivery->street) ? ' Улица: ' . $delivery->street : 'Самовывоз';
$subway = isset($delivery->subway) ? ' Метро: ' . $delivery->subway : '';
$block = isset($delivery->block) ? ' Корпус/Строение: ' . $delivery->block : '';
$floor = isset($delivery->floor) ? ' Этаж: ' . $delivery->floor : '';
$house = isset($delivery->house) ? ' Дом: ' . $delivery->house : '';
$address1 = $street . $subway . $block . $floor . $house;
$customer = new Customer(Configuration::get('YA_POKUPKI_CUSTOMER'));
$address = new Address();
$address->firstname = $customer->firstname;
$address->lastname = $customer->lastname;
$address->phone_mobile = isset($buyer->phone) ? $buyer->phone : 999999;
$address->postcode = isset($delivery->postcode) ? $delivery->postcode : 00;
$address->address1 = $address1;
$address->city = isset($delivery->city) ? $delivery->city : 'Город';
$address->alias = 'pokupki_' . substr(md5(time() . _COOKIE_KEY_), 0, 7);
$address->id_customer = $customer->id;
$address->id_country = Configuration::get('PS_COUNTRY_DEFAULT');
$address->save();
$cart->id_address_invoice = (int) $address->id;
$cart->id_address_delivery = (int) $address->id;
$id_address = (int) $address->id;
$cart->update();
$cart->id_customer = (int) $customer->id;
$this->context->cookie->id_customer = (int) $customer->id;
$this->context->cookie->write();
$b = array('address' => $address, 'customer' => $customer);
}
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
$a = array('cart' => $cart);
$dd = array_merge($a, $b);
return $dd;
}
示例6: postAdd
public function postAdd()
{
if (Request::ajax()) {
$productId = Input::get('productId');
$product = Product::findOrFail($productId);
$name = Input::get('name');
$price = Input::get('price');
$link = 'product/' . $product->link;
Cart::add(['id' => $productId, 'name' => $name, 'qty' => 1, 'price' => $price, 'options' => ['link' => $link]]);
return Response::json(array('productId' => $productId, 'name' => $name, 'price' => $price, 'link' => $product->link));
}
}
示例7: testMakeNewOrderNotWorking
/**
* @expectedException App\Exceptions\OrderCreationException
*/
public function testMakeNewOrderNotWorking()
{
$worker = \App::make('App\\Droit\\Shop\\Order\\Worker\\OrderWorkerInterface');
// Price 2.00 chf
\Cart::add(55, 'Uno', 1, '100', array('weight' => 155));
$shipping = factory(App\Droit\Shop\Shipping\Entities\Shipping::class)->make();
$cart = factory(App\Droit\Shop\Cart\Entities\Cart::class)->make();
$user = factory(App\Droit\User\Entities\User::class)->make();
$this->user->shouldReceive('find')->once()->andReturn($user);
$this->order->shouldReceive('newOrderNumber')->once()->andReturn('2015-00000003');
$this->order->shouldReceive('create')->once()->andReturn(null);
$this->cart->shouldReceive('create')->once()->andReturn($cart);
$result = $worker->make($shipping);
}
示例8: requestAction
public function requestAction()
{
global $smarty, $cookie, $cart, $link;
parent::requestAction();
if (!Validate::isLoadedObject($cart) && isset($cookie->id_cart)) {
$cart = new Cart((int) $cookie->id_cart);
}
if (Tools::isSubmit('addToCart')) {
if (!isset($cart) || !Validate::isLoadedObject($cart)) {
$cart = new Cart();
$cart->copyFromPost();
if ($cart->add()) {
$cookie->id_cart = $cart->id;
}
}
if (Tools::getRequest('id_product')) {
$id_product = Tools::getRequest('id_product');
}
if (Tools::getRequest('quantity')) {
$quantity = Tools::getRequest('quantity');
}
if (Tools::getRequest('id_attributes')) {
$attributes = Tools::getRequest('id_attributes');
}
$product = new Product(intval($id_product));
if (Validate::isLoadedObject($cart)) {
$cart->addProduct($id_product, $quantity, $product->price, $attributes);
}
Tools::redirect($link->getPage('CartView'));
}
if (isset($_GET['delete']) and intval($_GET['delete']) > 0) {
$cart->deleteProduct(intval($_GET['delete']));
Tools::redirect($link->getPage('CartView'));
}
if (Tools::isSubmit('cart_update')) {
$quantitys = Tools::getRequest('quantity');
if (count($quantitys) > 0) {
foreach ($quantitys as $key => $val) {
$cart->updateProduct($key, $val['quantity']);
}
}
Tools::redirect($link->getPage('CartView'));
}
if (isset($cart) && Validate::isLoadedObject($cart)) {
$this->cart_info = $cart->getCartInfo();
$this->cart_info["cart_msg"] = $cart->msg;
}
$smarty->assign(array('cart_products' => $this->cart_info['cart_products'], 'cart_quantity' => $this->cart_info['cart_quantity'], 'cart_msg' => $this->cart_info['cart_msg'], 'cart_discount' => $this->cart_info['cart_discount'], 'cart_shipping' => $this->cart_info['cart_shipping'], 'cart_total' => $this->cart_info['cart_total'], 'enjoy_free_shipping' => (double) Configuration::get('ENJOY_FREE_SHIPPING')));
}
示例9: getItem
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function getItem()
{
if (Request::ajax()) {
$inp = Input::all();
$misc = Misc::where('item_id', '=', $inp['id'])->where('item_talla', '=', $inp['talla'])->where('item_color', '=', $inp['color'])->where('deleted', '=', 0)->first();
$aux = Misc::where('item_id', '=', $inp['id'])->where('deleted', '=', 0)->first();
$img = Images::where('deleted', '!=', 1)->where('misc_id', '=', $aux->id)->first();
$talla = Tallas::find($inp['talla']);
$color = Colores::find($inp['color']);
Cart::add(array('id' => $inp['id'], 'name' => $inp['name'], 'qty' => 1, 'options' => array('misc' => $misc->id, 'img' => $img->image, 'talla' => $inp['talla'], 'talla_desc' => $talla->talla_desc, 'color' => $inp['color'], 'color_desc' => $color->color_desc), 'price' => $inp['price']));
$rowid = Cart::search(array('id' => $inp['id'], 'options' => array('talla' => $inp['talla'], 'color' => $inp['color'])));
$item = Cart::get($rowid[0]);
return Response::json(array('rowid' => $rowid[0], 'img' => $img->image, 'id' => $item->id, 'name' => $item->name, 'talla' => $talla->talla_desc, 'color' => $color->color_desc, 'qty' => $item->qty, 'price' => $item->price, 'subtotal' => $item->subtotal, 'cantArt' => Cart::count(), 'total' => Cart::total()));
}
}
示例10: addtocart
public function addtocart($goods_id)
{
$msg = array();
if (!$goods_id) {
$msg['error'] = '-1';
$msg['msg'] = '加入购物车失败!';
echo json_encode($msg);
throw new Exception('exit');
}
$goods_id = (int) $goods_id;
//模拟下单start
$uid = LuS::get('uid');
$data['goods_id'] = $goods_id;
$data['goods_num'] = 1;
// $data = $goods_id;
//购物车已经存在$goods_id商品的数量
$cart_goods_info = Cart::getCartGoodsInfoByGoodsId($uid, $goods_id);
//检查库存
$goods_info = AdminGoodsM::getGoodsInfoByGoodsId($goods_id);
if ($goods_info['goods_num'] < $data['goods_num'] + $cart_goods_info['goods_num']) {
$msg['error'] = '-2';
$msg['msg'] = '库存不足!';
echo json_encode($msg);
throw new Exception('exit');
}
//添加
$add_rs = Cart::add($uid, $data);
if ($add_rs) {
//模拟下单end
$msg['error'] = '1';
$msg['msg'] = '加入购物车成功!';
$msg['num'] = Cart::getCount($uid);
} else {
//模拟下单end
$msg['error'] = '-1';
$msg['msg'] = '加入购物车失败!';
}
echo json_encode($msg);
throw new Exception('exit');
}
示例11: add_some_extra
$total = 0.00;
$unit = '';
$callback = function ($quantity, $product) use ($tax, &$total, &$unit) {
$pricePerItem = constant(__CLASS__ . "::PRICE_" . strtoupper($product));
$total += ($pricePerItem * $quantity) * ($tax + 1.0);
$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);
示例12: add_to_cart
public function add_to_cart($return = 'return')
{
if (!\Input::post()) {
return false;
}
// check for a valid CSRF token
// if (!\Security::check_token())
// {
// \Messages::error('CSRF attack or expired CSRF token.');
// return false;
// }
$post = \Input::post();
$product_id = $post['product_id'];
if (!($product = Model_Product::find_one_by_id($product_id))) {
return;
}
$selected_attributes = array();
$selected_attributes_json = null;
if (isset($post['select']) && !empty($post['select'])) {
ksort($post['select']);
$selected_attributes_json = json_encode($post['select']);
}
$product_data = Model_Product::product_data($product, $selected_attributes_json, \Input::post('select'), \Input::post('attributeid'));
if (!empty($product_data)) {
$attr_obj = null;
if (!empty($product_data['current_attributes'])) {
$attr_obj = $product_data['current_attributes'][0]->product_attribute;
}
$item = array('title' => $product->title, 'id' => $product->id, 'product_attribute_id' => $attr_obj ? $attr_obj->id : null, 'quantity' => $post['quantity'], 'attributes' => $attr_obj ? $attr_obj->attributes : null, 'product_code' => $product_data['code'], 'unique_id' => uniqid());
if ($product_data['sale']) {
$item += array('price' => $product_data['sale'], 'price_type' => 'sale_price');
} else {
$item += array('price' => $product_data['retail_price'], 'price_type' => 'retail_price');
}
$stock_options = \Config::load('stock-option.db');
if ($stock_options['allow_buy_out_of_stock'] != 1 && $product_data['stock_quantity'] < 1) {
\Messages::error('Product is Out of Stock.');
echo \Messages::display();
return;
}
$uid = \Cart::generateUID($item);
if (\Cart::exists($uid)) {
$cart_item = \Cart::item($uid);
$quantity = $cart_item->get('quantity');
if ($product_data['stock_quantity'] > 0 && $product_data['stock_quantity'] <= $quantity) {
\Messages::error($product->title . ' has not enough stock to fulfill your request.');
echo \Messages::display();
return;
}
}
if ($return == 'return') {
\Cart::add($item);
// Always return cart item id
$uid = \Cart::generateUID($item);
if (\Cart::exists($uid)) {
return $uid;
}
return false;
} else {
$uid = \Cart::generateUID($item);
if (\Cart::exists($uid)) {
echo $uid;
}
echo '';
exit;
}
\Messages::success('Product successfully added to cart.');
echo \Messages::display();
}
return false;
}
示例13: _getCart
private function _getCart($id_customer, $id_address_billing, $id_address_shipping, $productsNode, $currency, $shipping_method)
{
$cart = new Cart();
$cart->id_customer = $id_customer;
$cart->id_address_invoice = $id_address_billing;
$cart->id_address_delivery = $id_address_shipping;
$cart->id_currency = Currency::getIdByIsoCode((string) $currency == '' ? 'EUR' : (string) $currency);
$cart->id_lang = Configuration::get('PS_LANG_DEFAULT');
$cart->recyclable = 0;
$cart->secure_key = md5(uniqid(rand(), true));
$actual_configuration = unserialize(Configuration::get('SHOPPING_FLUX_SHIPPING_MATCHING'));
$carrier_to_load = isset($actual_configuration[base64_encode(Tools::safeOutput($shipping_method))]) ? (int) $actual_configuration[base64_encode(Tools::safeOutput($shipping_method))] : (int) Configuration::get('SHOPPING_FLUX_CARRIER');
$carrier = Carrier::getCarrierByReference($carrier_to_load);
//manage case PS_CARRIER_DEFAULT is deleted
$carrier = is_object($carrier) ? $carrier : new Carrier($carrier_to_load);
$cart->id_carrier = $carrier->id;
$cart->add();
foreach ($productsNode->Product as $product) {
$skus = explode('_', $product->SKU);
$added = $cart->updateQty((int) $product->Quantity, (int) $skus[0], isset($skus[1]) ? $skus[1] : null);
if ($added < 0 || $added === false) {
return false;
}
}
$cart->update();
return $cart;
}
示例14: addOrder
public function addOrder(ShopgateOrder $order)
{
$this->log("PS start add_order", ShopgateLogger::LOGTYPE_DEBUG);
$shopgateOrder = PSShopgateOrder::instanceByOrderNumber($order->getOrderNumber());
if ($shopgateOrder->id) {
throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_DUPLICATE_ORDER, 'external_order_id: ' . $shopgateOrder->id_order, true);
}
$comments = array();
// generate products array
$products = $this->insertOrderItems($order);
//Get or create customer
$id_customer = Customer::customerExists($order->getMail(), true, false);
$customer = new Customer($id_customer ? $id_customer : (int) $order->getExternalCustomerId());
if (!$customer->id) {
$customer = $this->createCustomer($customer, $order);
}
// prepare addresses: company has to be shorten. add mobile phone / telephone
$this->prepareAddresses($order);
//Get invoice and delivery addresses
$invoiceAddress = $this->getPSAddress($customer, $order->getInvoiceAddress());
$deliveryAddress = $order->getInvoiceAddress() == $order->getDeliveryAddress() ? $invoiceAddress : $this->getPSAddress($customer, $order->getDeliveryAddress());
//Creating currency
$this->log("PS setting currency", ShopgateLogger::LOGTYPE_DEBUG);
$id_currency = $order->getCurrency() ? Currency::getIdByIsoCode($order->getCurrency()) : $this->id_currency;
$currency = new Currency($id_currency ? $id_currency : $this->id_currency);
//Creating new cart
$this->log("PS set cart variables", ShopgateLogger::LOGTYPE_DEBUG);
$cart = new Cart();
$cart->id_lang = $this->id_lang;
$cart->id_currency = $currency->id;
$cart->id_address_delivery = $deliveryAddress->id;
$cart->id_address_invoice = $invoiceAddress->id;
$cart->id_customer = $customer->id;
if (version_compare(_PS_VERSION_, '1.4.1.0', '>=')) {
// id_guest is a connection to a ps_guest entry which includes screen width etc.
// is_guest field only exists in Prestashop 1.4.1.0 and higher
$cart->id_guest = $customer->is_guest;
}
$cart->recyclable = 0;
$cart->gift = 0;
$cart->id_carrier = (int) Configuration::get('SHOPGATE_CARRIER_ID');
$cart->secure_key = $customer->secure_key;
$this->log("PS try to create cart", ShopgateLogger::LOGTYPE_DEBUG);
if (!$cart->add()) {
throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_DATABASE_ERROR, 'Unable to create cart', true);
}
//Adding items to cart
$this->log("PS adding items to cart", ShopgateLogger::LOGTYPE_DEBUG);
foreach ($products as $p) {
$this->log("PS cart updateQty product id: " . $p['id_product'], ShopgateLogger::LOGTYPE_DEBUG);
$this->log("PS cart updateQty product quantity: " . $p['quantity'], ShopgateLogger::LOGTYPE_DEBUG);
$this->log("PS cart updateQty product quantity_difference: " . $p['quantity_difference'], ShopgateLogger::LOGTYPE_DEBUG);
$this->log("PS cart updateQty product id_product_attribute: " . $p['id_product_attribute'], ShopgateLogger::LOGTYPE_DEBUG);
$this->log("PS cart updateQty product delivery address: " . $deliveryAddress->id, ShopgateLogger::LOGTYPE_DEBUG);
//TODO deal with customizations
$id_customization = false;
if ($p['quantity'] - $p['quantity_difference'] > 0) {
// only if the result of $p['quantity'] - $p['quantity_difference'] is higher then 0
$cart->updateQty($p['quantity'] - $p['quantity_difference'], $p['id_product'], $p['id_product_attribute'], $id_customization, 'up', $deliveryAddress->id);
}
if ($p['quantity_difference'] > 0) {
$this->log("PS try to add cart message ", ShopgateLogger::LOGTYPE_DEBUG);
$message = new Message();
$message->id_cart = $cart->id;
$message->private = 1;
$message->message = 'Warning, wanted quantity for product "' . $p['name'] . '" was ' . $p['quantity'] . ' unit(s), however, the amount in stock is ' . $p['quantity_in_stock'] . ' unit(s). Only ' . $p['quantity_in_stock'] . ' unit(s) were added to the order';
$message->save();
}
}
$id_order_state = 0;
$shopgate = new Shopgate();
$payment_name = $shopgate->getTranslation('Mobile Payment');
$this->log("PS map payment method", ShopgateLogger::LOGTYPE_DEBUG);
if (!$order->getIsShippingBlocked()) {
$id_order_state = $this->getOrderStateId('PS_OS_PREPARATION');
switch ($order->getPaymentMethod()) {
case 'SHOPGATE':
$payment_name = $shopgate->getTranslation('Shopgate');
break;
case 'PREPAY':
$payment_name = $shopgate->getTranslation('Bankwire');
$id_order_state = $this->getOrderStateId('PS_OS_BANKWIRE');
break;
case 'COD':
$payment_name = $shopgate->getTranslation('Cash on Delivery');
break;
case 'PAYPAL':
$payment_name = $shopgate->getTranslation('PayPal');
break;
default:
break;
}
} else {
$id_order_state = $this->getOrderStateId('PS_OS_SHOPGATE');
switch ($order->getPaymentMethod()) {
case 'SHOPGATE':
$payment_name = $shopgate->getTranslation('Shopgate');
break;
case 'PREPAY':
$payment_name = $shopgate->getTranslation('Bankwire');
//.........这里部分代码省略.........
示例15: createOrder
/**
* Creating of the PrestaShop order
* @param $neteven_order
* @param $neteven_orders
* @return int
*/
private function createOrder($neteven_order, $neteven_orders)
{
if (constant('_PS_VERSION_') >= 1.5) {
include_once dirname(__FILE__) . '/OrderInvoiceOverride.php';
}
// Treatment of customer
$id_customer = $this->addCustomerInBDD($neteven_order);
if ($this->time_analyse) {
$this->current_time_2 = time();
Toolbox::displayDebugMessage(self::getL('Customer') . ' : ' . ((int) $this->current_time_2 - (int) $this->current_time_0) . 's');
}
// Treatment of addresses of the customer
$id_address_billing = $this->addAddresseInBDD($neteven_order->OrderID, $neteven_order->BillingAddress, 'facturation', $id_customer);
$id_address_shipping = $this->addAddresseInBDD($neteven_order->OrderID, $neteven_order->ShippingAddress, 'livraison', $id_customer);
if ($this->time_analyse) {
$this->current_time_0 = time();
Toolbox::displayDebugMessage(self::getL('Address') . ' : ' . ((int) $this->current_time_0 - (int) $this->current_time_2) . 's');
}
// Get secure key of customer
$secure_key_default = md5(uniqid(rand(), true));
if ($secure_key = Db::getInstance()->getValue('SELECT `secure_key` FROM `' . _DB_PREFIX_ . 'customer` WHERE `id_customer` = ' . (int) $id_customer)) {
$secure_key_default = $secure_key;
} else {
Toolbox::addLogLine(self::getL('Problem with a secure key recovery for the customer / NetEven Order Id') . ' ' . $neteven_order->OrderID);
}
// Treatment of order informations
$total_wt = 0;
$total_product = 0;
$total_product_wt = 0;
foreach ($neteven_orders as $neteven_order_temp) {
if ($neteven_order_temp->OrderID == $neteven_order->OrderID) {
if (in_array($neteven_order_temp->Status, $this->getValue('t_list_order_status'))) {
continue;
}
$total_product += floatval($neteven_order_temp->Price->_) - floatval($neteven_order_temp->VAT->_);
$total_product_wt += floatval($neteven_order_temp->Price->_);
}
}
$total_wt = $total_product_wt + $neteven_order->OrderShippingCost->_;
$date_now = date('Y-m-d H:i:s');
if ($this->time_analyse) {
$this->current_time_2 = time();
Toolbox::displayDebugMessage(self::getL('Order total') . ' : ' . ((int) $this->current_time_2 - (int) $this->current_time_0) . 's');
}
// Creating and add order in PrestaShop
if (!($res = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'orders_gateway` WHERE `id_order_neteven` = ' . (int) $neteven_order->OrderID . ' AND `id_order_detail_neteven` = 0'))) {
// Creating cart
$cart = new Cart();
$cart->id_address_delivery = (int) $id_address_shipping;
$cart->id_address_invoice = (int) $id_address_billing;
$cart->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT');
$cart->id_customer = (int) $id_customer;
$cart->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$cart->id_carrier = (int) Configuration::get('PS_CARRIER_DEFAULT');
$cart->recyclable = 1;
$cart->gift = 0;
$cart->gift_message = '';
$cart->date_add = $date_now;
$cart->secure_key = $secure_key_default;
$cart->date_upd = $date_now;
if (!$cart->add()) {
Toolbox::addLogLine(self::getL('Failed for cart creation / NetEven Order Id') . ' ' . (int) $neteven_order->OrderID);
}
if ($this->time_analyse) {
$this->current_time_0 = time();
Toolbox::displayDebugMessage(self::getL('Cart') . ' : ' . ((int) $this->current_time_0 - (int) $this->current_time_2) . 's');
}
// Creating order
$id_order_temp = 0;
$order = new Order();
$order->id_carrier = Configuration::get('PS_CARRIER_DEFAULT');
$order->id_lang = Configuration::get('PS_LANG_DEFAULT');
$order->id_customer = $id_customer;
$order->id_cart = $cart->id;
$order->id_currency = Configuration::get('PS_CURRENCY_DEFAULT');
$order->id_address_delivery = $id_address_shipping;
$order->id_address_invoice = $id_address_billing;
$order->secure_key = $secure_key_default;
$order->payment = $neteven_order->PaymentMethod;
$order->conversion_rate = 1;
$order->module = 'nqgatewayneteven';
$order->recyclable = 0;
$order->gift = 0;
$order->gift_message = '';
$order->shipping_number = '';
//generate reference order
$nbr_order_neteven = Configuration::get('NUMBER_ORDER_NETEVEN');
if (false === $nbr_order_neteven) {
$nbr_order_neteven = 1;
} else {
$nbr_order_neteven = (int) str_replace('N', '', $nbr_order_neteven);
$nbr_order_neteven++;
}
$next_ref_gen_order_neteven = 'N' . sprintf('%07s', $nbr_order_neteven);
//.........这里部分代码省略.........