コード例 #1
0
ファイル: Cart66Usps.php プロジェクト: rbredow/allyzabbacart
 public function getIntlRates($zipOrigin, $countryCode, $value, $pounds = 0, $ounces = 0, $commercial = 'N', $mailType = 'Package', $container = 'VARIABLE', $size = "REGULAR", $machinable = 'true', $width = 10, $length = 15, $height = 10, $girth = 0)
 {
     $rateReq = 'IntlRateV2Request USERID="' . $this->_uspsUsername . '"';
     $countryName = Cart66Common::getCountryName($countryCode);
     $weight = $this->_convertToPoundOunces($pounds);
     $pounds = $weight->pounds;
     $ounces += $weight->ounces;
     $data = array('Revision' => '4', 'Package ID="1"' => array('Pounds' => $pounds, 'Ounces' => $ounces, 'Machinable' => $machinable, 'MailType' => $mailType, 'ValueOfContents' => $value, 'Country' => $countryName, 'Container' => $container, 'Size' => $size, 'Width' => $width, 'Length' => $length, 'Height' => $height, 'Girth' => $girth, 'OriginZip' => $zipOrigin));
     $xml = Cart66Common::arrayToXml($data, $rateReq);
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] USPS Intl rate request xml:\n{$xml}");
     $url = 'http://production.shippingapis.com/ShippingAPI.dll?API=IntlRateV2&Xml=' . urlencode($xml);
     $result = Cart66Common::curl($url);
     // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] USPS Result:\n" . $result);
     $this->_parseIntlResult($result);
     return $this->_rates;
 }
コード例 #2
0
 /**
  * Store order in database after successful transaction is processed
  */
 public function saveOrder($total, $tax, $transId, $status, $accountId = 0)
 {
     $address = $this->getShipping();
     $b = $this->getBilling();
     $p = $this->getPayment();
     $orderInfo['ship_first_name'] = $address['firstName'];
     $orderInfo['ship_last_name'] = $address['lastName'];
     $orderInfo['ship_address'] = $address['address'];
     $orderInfo['ship_address2'] = $address['address2'];
     $orderInfo['ship_city'] = $address['city'];
     $orderInfo['ship_state'] = $address['state'];
     $orderInfo['ship_zip'] = $address['zip'];
     $orderInfo['ship_country'] = Cart66Common::getCountryName($address['country']);
     $orderInfo['bill_first_name'] = $b['firstName'];
     $orderInfo['bill_last_name'] = $b['lastName'];
     $orderInfo['bill_address'] = $b['address'];
     $orderInfo['bill_address2'] = $b['address2'];
     $orderInfo['bill_city'] = $b['city'];
     $orderInfo['bill_state'] = $b['state'];
     $orderInfo['bill_zip'] = $b['zip'];
     $orderInfo['bill_country'] = Cart66Common::getCountryName($b['country']);
     $orderInfo['phone'] = preg_replace("/[^0-9]/", "", $p['phone']);
     $orderInfo['email'] = $p['email'];
     $orderInfo['custom_field'] = isset($p['custom-field']) ? $p['custom-field'] : '';
     $orderInfo['coupon'] = Cart66Common::getPromoMessage();
     $orderInfo['tax'] = $tax;
     $orderInfo['shipping'] = Cart66Session::get('Cart66Cart')->getShippingCost();
     $orderInfo['subtotal'] = Cart66Session::get('Cart66Cart')->getSubTotal();
     $orderInfo['total'] = preg_replace("/[^0-9\\.]/", "", $total);
     $orderInfo['trans_id'] = $transId;
     $orderInfo['status'] = $status;
     $orderInfo['ordered_on'] = date('Y-m-d H:i:s', Cart66Common::localTs());
     $orderInfo['shipping_method'] = Cart66Session::get('Cart66Cart')->getShippingMethodName();
     $orderInfo['account_id'] = $accountId;
     $additional_fields = array();
     $custom_payment_fields = apply_filters('cart66_after_payment_form', '');
     if (is_array($custom_payment_fields)) {
         foreach ($custom_payment_fields as $key => $payment_field) {
             if (isset($p[$payment_field['slug']])) {
                 $additional_fields[$payment_field['section']][$payment_field['slug']] = array('label' => $payment_field['label'], 'value' => $p[$payment_field['slug']]);
             }
         }
     }
     $custom_billing_fields = apply_filters('cart66_after_billing_form', '');
     if (is_array($custom_billing_fields)) {
         foreach ($custom_billing_fields as $key => $billing_field) {
             if (isset($b[$billing_field['slug']])) {
                 $additional_fields[$billing_field['section']][$billing_field['slug']] = array('label' => $billing_field['label'], 'value' => $b[$billing_field['slug']]);
             }
         }
     }
     $custom_shipping_fields = apply_filters('cart66_after_shipping_form', '');
     if (is_array($custom_shipping_fields)) {
         foreach ($custom_shipping_fields as $key => $shipping_field) {
             if (isset($address[$shipping_field['slug']])) {
                 $additional_fields[$shipping_field['section']][$shipping_field['slug']] = array('label' => $shipping_field['label'], 'value' => $address[$shipping_field['slug']]);
             }
         }
     }
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] additional fields: " . print_r($additional_fields, true));
     if (!empty($additional_fields)) {
         $orderInfo['additional_fields'] = serialize($additional_fields);
     }
     $orderInfo = Cart66Common::deNullArrayValues($orderInfo);
     $orderId = Cart66Session::get('Cart66Cart')->storeOrder($orderInfo);
     return $orderId;
 }
コード例 #3
0
 /**
  * Return an array of data matching the rows in the Cart66 orders table for the given order.
  *
  * @param array The order as retrieved from mijireh
  * @return array
  */
 public function buildOrderDataArray($cloud_order)
 {
     $statusOptions = Cart66Common::getOrderStatusOptions();
     $status = $statusOptions[0];
     $order_token = $cloud_order['order_number'] . $cloud_order['email'];
     $ouid = md5($order_token);
     $order_info = array('trans_id' => $cloud_order['order_number'], 'authorization' => $cloud_order['authorization'], 'shipping' => $cloud_order['shipping'], 'shipping_method' => $cloud_order['meta_data']['shipping_method'], 'subtotal' => $cloud_order['subtotal'], 'discount_amount' => $cloud_order['discount'], 'tax' => $cloud_order['tax'], 'total' => $cloud_order['total'], 'status' => $status, 'email' => $cloud_order['email'], 'bill_first_name' => $cloud_order['first_name'], 'bill_last_name' => $cloud_order['last_name'], 'ordered_on' => $cloud_order['order_date'], 'ouid' => $ouid, 'coupon' => $cloud_order['meta_data']['coupon'], 'custom_field' => $cloud_order['meta_data']['custom-field']);
     if (isset($cloud_order['shipping_address']) && is_array($cloud_order['shipping_address'])) {
         $address = $cloud_order['shipping_address'];
         $order_info['ship_first_name'] = $address['first_name'];
         $order_info['ship_last_name'] = $address['last_name'];
         $order_info['ship_address'] = $address['street'];
         $order_info['ship_address2'] = $address['apt_suite'];
         $order_info['ship_city'] = $address['city'];
         $order_info['ship_state'] = $address['state_province'];
         $order_info['ship_zip'] = $address['zip_code'];
         $order_info['ship_country'] = Cart66Common::getCountryName($address['country']);
         $order_info['phone'] = $address['phone'];
     }
     return $order_info;
 }