本文整理汇总了PHP中Rest::orderDetail方法的典型用法代码示例。如果您正苦于以下问题:PHP Rest::orderDetail方法的具体用法?PHP Rest::orderDetail怎么用?PHP Rest::orderDetail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rest
的用法示例。
在下文中一共展示了Rest::orderDetail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validation
public function validation()
{
if (!$this->active || !Configuration::get('GOINTERPAY_STORE') || !Configuration::get('GOINTERPAY_SECRET')) {
return false;
}
if (!isset($_GET['orderId'])) {
return false;
}
include_once _PS_MODULE_DIR_ . 'gointerpay/Rest.php';
$rest = new Rest(Configuration::get('GOINTERPAY_STORE'), Configuration::get('GOINTERPAY_SECRET'));
$result = $rest->orderDetail(Tools::safeOutput(Tools::getValue('orderId')));
$cart = new Cart((int) $result['cartId']);
$original_total = Tools::ps_round((double) $cart->getOrderTotal(true, Cart::BOTH), 2);
/* Check the currency code */
$id_currency_new = (int) Currency::getIdByIsoCode($result['foreignCurrencyCode']);
if ($id_currency_new) {
$cart->id_currency = (int) $id_currency_new;
$cart->save();
} else {
die('Sorry, we were not able to accept orders in the following currency: ' . Tools::safeOutput($result['foreignCurrencyCode']));
}
$name = explode(" ", $result['delivery_address']['name']);
$lastname = " - ";
if (isset($name[1])) {
$lastname = $name[1];
}
/* Update the delivery and billing address */
$delivery_address = new Address((int) $cart->id_address_delivery);
$delivery_address->firstname = $name[0];
$delivery_address->lastname = $lastname;
$delivery_address->company = $result['delivery_address']['company'];
$delivery_address->phone = $result['delivery_address']['phone'];
$delivery_address->phone_mobile = $result['delivery_address']['altPhone'];
$delivery_address->id_country = (int) Country::getByIso($result['delivery_address']['countryCode']);
$delivery_address->id_state = (int) State::getIdByIso($result['delivery_address']['state'], (int) $delivery_address->id_country);
$delivery_address->address1 = $result['delivery_address']['address1'];
$delivery_address->address2 = $result['delivery_address']['address2'];
$delivery_address->city = $result['delivery_address']['city'];
$delivery_address->postcode = $result['delivery_address']['zip'];
$delivery_address->save();
/* If no billing address specified, use the delivery address */
if ($result['invoice_address']['address1'] != '' || $result['invoice_address']['city'] != '') {
$invoice_name = explode(" ", $result['invoice_address']['name']);
$invoice_lastname = " - ";
if (isset($invoice_name[1])) {
$invoice_lastname = $invoice_name[1];
}
$invoice_address = new Address((int) $cart->id_address_invoice);
$invoice_address->firstname = $invoice_name[0];
$invoice_address->lastname = $invoice_lastname;
$invoice_address->company = $result['invoice_address']['company'];
$invoice_address->phone = $result['invoice_address']['phone'];
$invoice_address->phone_mobile = $result['invoice_address']['altPhone'];
$invoice_address->id_country = (int) Country::getByIso($result['invoice_address']['countryCode']);
$invoice_address->id_state = (int) State::getIdByIso($result['invoice_address']['state'], (int) $invoice_address->id_country);
$invoice_address->address1 = $result['invoice_address']['address1'];
$invoice_address->address2 = $result['invoice_address']['address2'];
$invoice_address->city = $result['invoice_address']['city'];
$invoice_address->postcode = $result['invoice_address']['zip'];
if ($cart->id_address_delivery == $cart->id_address_invoice) {
$invoice_address->add();
$cart->id_address_invoice = (int) $invoice_address->id;
$cart->save();
} else {
$invoice_address->save();
}
}
/* Store the Order ID and Shipping cost */
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'gointerpay_order_id` (`id_cart`, `orderId`, `shipping`, `shipping_orig`, `taxes`, `total`, `products`, `status`)
VALUES (\'' . (int) $cart->id . '\', \'' . pSQL(Tools::getValue('orderId')) . '\', \'' . (double) $result['shippingTotal'] . '\', \'' . (double) $result['shippingTotalForeign'] . '\', \'' . (double) $result['quotedDutyTaxes'] . '\', \'' . (double) $result['grandTotal'] . '\', \'' . (double) $result['itemsTotal'] . '\', \'Init\')');
/* Add the duties and taxes */
Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'specific_price` WHERE id_customer = ' . (int) $cart->id_customer . ' AND id_product = ' . (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES'));
$specific_price = new SpecificPrice();
$specific_price->id_product = (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES');
$specific_price->id_shop = 0;
$specific_price->id_country = 0;
$specific_price->id_group = 0;
$specific_price->id_cart = (int) $cart->id;
$specific_price->id_product_attribute = 0;
$specific_price->id_currency = $cart->id_currency;
$specific_price->id_customer = $cart->id_customer;
$specific_price->price = (double) $result['quotedDutyTaxesForeign'];
$specific_price->from_quantity = 1;
$specific_price->reduction = 0;
$specific_price->reduction_type = 'percentage';
$specific_price->from = date('Y-m-d H:i:s');
$specific_price->to = strftime('%Y-%m-%d %H:%M:%S', time() + 10);
$specific_price->add();
if (Validate::isLoadedObject($specific_price)) {
$cart->updateQty(1, (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES'));
}
$result['status'] = 'Pending';
$total = Tools::ps_round((double) $cart->getOrderTotal(true, Cart::BOTH), 2);
$message = '
Total paid on Interpay: ' . (double) $result['grandTotalForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
Duties and taxes on Interpay: ' . (double) $result['quotedDutyTaxesForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
Shipping on Interpay: ' . (double) $result['shippingTotalForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
Currency: ' . $result['foreignCurrencyCode'];
if ($result['status'] == 'Pending') {
$this->context->cart->id = (int) $result['cartId'];
//.........这里部分代码省略.........