public function accountCreate($attrs)
 {
     $render_form = false;
     if (isset($attrs['product'])) {
         $product = new Cart66Product();
         $product->load($attrs['product']);
         if ($product->id <= 0) {
             $product->loadByItemNumber($attrs['product']);
         }
         if ($product->isMembershipProduct() || $product->isPayPalSubscription()) {
             $render_form = true;
         }
     }
     $data = array('attrs' => $attrs, 'render_form' => $render_form);
     $view = Cart66Common::getView('pro/views/account-create.php', $data);
     return $view;
 }
Exemplo n.º 2
0
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Unable to process order: " . print_r($errors, true));
                 throw new Cart66Exception(__('Your order could not be processed for the following reasons:', 'cart66'), 66500);
             } catch (Cart66Exception $e) {
                 $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage(), $errors);
                 echo Cart66Common::getView('views/error-messages.php', $exception);
             }
         }
     }
     if ($create_account) {
         $account->save();
         $accountId = $account->id;
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Just created account with id: {$accountId}");
         $product = new Cart66Product();
         $product->load($data['attrs']['product']);
         if ($product->id <= 0) {
             $product->loadByItemNumber($data['attrs']['product']);
         }
         if ($product->id > 0) {
             $account->attachMembershipProduct($product, $account->firstName, $account->lastName);
             $accountId = $account->id;
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Attached membership to account id: {$accountId}");
         }
         if ($account->login($acctData['username'], $acctData['password'])) {
             Cart66Session::set('Cart66AccountId', $account->id);
         }
         if (isset($data['attrs']['url'])) {
             wp_redirect($data['attrs']['url']);
             exit;
         }
     }
 }
Exemplo n.º 3
0
 public static function shipLink($order)
 {
     $endiciaBaseUrl = "endicia://newShipment2/?";
     $endiciaUrl = "";
     $ToAddress = $order->ship_first_name . " " . $order->ship_last_name . "%0D";
     $ToAddress .= $order->ship_address . "%0D";
     if (!empty($order->ship_address2)) {
         $ToAddress .= $order->ship_address2 . "%0D";
     }
     $ToAddress .= $order->ship_city . " " . $order->ship_state . " " . $order->ship_zip . "%0D";
     $ToAddress .= $order->ship_country;
     //$ToAddress = rawurlencode($ToAddress);
     if ($order->ship_country != "United States") {
         if (strpos($order->shipping_method, "First-Class")) {
             $MailClass = "INTLFIRST";
         } else {
             if (strpos($order->shipping_method, "Express")) {
                 $MailClass = "INTLEXPRESS";
             } else {
                 $MailClass = "INTLPRIORITY";
             }
         }
     } else {
         if (strpos($order->shipping_method, "Express")) {
             $MailClass = "EXPRESS";
         } else {
             if (strpos($order->shipping_method, "Priority")) {
                 $MailClass = "PRIORITY";
             } else {
                 $MailClass = "FIRST";
             }
         }
     }
     $shipweight = 0.0;
     $endiciaCustoms = "CustomsFormType=CN22;ContentsType=MERCHANDISE";
     $itemNum = 1;
     $totalProductCount = 0;
     foreach ($order->getItems() as $item) {
         $productCount = rawurlencode($item->quantity);
         $productPrice = rawurlencode($item->product_price * $item->quantity);
         $productName = rawurlencode($item->description);
         $totalProductCount += $productCount;
         $p = new Cart66Product();
         $p->loadByItemNumber($item->item_number);
         $lineWeight = $p->weight * $item->quantity;
         unset($p);
         $shipweight += $lineWeight;
         $lineWeightOz = sprintf("%0.1f", (double) $lineWeight * 16.0);
         $endiciaCustoms .= "CustomsQuantity{$itemNum}={$productCount};" . "CustomsDescription{$itemNum}={$item->description};" . "CustomsWeight{$itemNum}={$lineWeightOz};" . "CustomsValue{$itemNum}={$productPrice};" . "CustomsCountry{$itemNum}=" . Cart66Setting::getValue('endicia_countryOfOrigin') . ";";
         $itemNum += 1;
     }
     $ShipWeightOz = sprintf("%0.1f", (double) $shipweight * 16.0);
     $orderValue = $order->subtotal - $order->discount;
     // If the user wants all the customs info summarized into a single line, do that now
     if (Cart66Setting::getValue('enable_endiciaGenericProducts')) {
         $endiciaCustoms = "CustomsFormType=CN22;ContentsType=MERCHANDISE;";
         $endiciaCustoms .= "CustomsQuantity1={$totalProductCount};" . "CustomsDescription1=" . Cart66Setting::getValue('endicia_productDescription') . ";" . "CustomsWeight1={$ShipWeightOz};" . "CustomsValue1={$orderValue};" . "CustomsCountry1=" . Cart66Setting::getValue('endicia_countryOfOrigin') . ";";
     }
     $endiciaUrl = "ToAddress={$ToAddress}" . ";ReferenceID={$order->trans_id}" . ";ToEMail={$order->email}" . ";MailClass={$MailClass}" . ";WeightOz={$ShipWeightOz}" . ";Value={$orderValue}" . ";Description=" . Cart66Setting::getValue('endicia_productDescription') . ";Stealth=TRUE" . ";{$endiciaCustoms}";
     return $endiciaBaseUrl . $endiciaUrl;
 }
Exemplo n.º 4
0
 public function saveMijirehOrder($order_number)
 {
     global $wpdb;
     // Make sure the order is not already in the database
     $orders_table = Cart66Common::getTableName('orders');
     $sql = "select id from {$orders_table} where trans_id = %s";
     $sql = $wpdb->prepare($sql, $order_number);
     $order_id = $wpdb->get_var($sql);
     if (!$order_id) {
         // Save the order
         $order = new Cart66Order();
         $cloud_order = $this->pullOrder($order_number);
         $order_data = $this->buildOrderDataArray($cloud_order);
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Order data: " . print_r($order_data, true));
         $order_data = Cart66Common::deNullArrayValues($order_data);
         $order_id = $order->rawSave($order_data);
         // Save the order items
         $order_items_table = Cart66Common::getTableName('order_items');
         foreach ($cloud_order['items'] as $key => $item) {
             $product = new Cart66Product();
             $product->loadByItemNumber($item['sku']);
             $data = array('order_id' => $order_id, 'product_id' => $product->id, 'product_price' => $item['price'], 'item_number' => $item['sku'], 'description' => $item['name'], 'quantity' => $item['quantity'], 'duid' => md5($order_id . $item['sku']));
             // Look for gravity forms data
             if (isset($cloud_order['meta_data'][$key]['gforms_' . $item['sku']])) {
                 $data['form_entry_ids'] = $cloud_order['meta_data'][$key]['gforms_' . $item['sku']];
             }
             $fIds = array();
             if (isset($data['form_entry_ids'])) {
                 $fIds = explode(',', $data['form_entry_ids']);
                 if (is_array($fIds) && count($fIds)) {
                     foreach ($fIds as $entryId) {
                         if (class_exists('RGFormsModel')) {
                             if ($lead = RGFormsModel::get_lead($entryId)) {
                                 $lead['status'] = 'active';
                                 RGFormsModel::update_lead($lead);
                             }
                         }
                     }
                 }
             }
             $data = Cart66Common::deNullArrayValues($data);
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to save this order item:" . print_r($data, true));
             $wpdb->insert($order_items_table, $data);
             $order_item_id = $wpdb->insert_id;
             // Decrement inventory after sale
             if (Cart66Setting::getValue('track_inventory') == 1) {
                 $option_info = '';
                 if (isset($cloud_order['meta_data']['options_' . $item['sku']])) {
                     $option_info = $cloud_order['meta_data']['options_' . $item['sku']];
                 }
                 Cart66Product::decrementInventory($data['product_id'], $option_info, $data['quantity']);
             }
             // Look for membership product upgrades/extensions
             if (isset($cloud_order['meta_data']['account_id']) && is_numeric($cloud_order['meta_data']['account_id'])) {
                 $order->load($order_id);
                 $account_id = $cloud_order['meta_data']['account_id'];
                 if ($mp = $order->getMembershipProduct()) {
                     $account = new Cart66Account();
                     $account->load($account_id);
                     $account->attachMembershipProduct($mp, $account->firstName, $account->lastName);
                     $order->account_id = $account->id;
                     $order->save();
                 }
             }
         }
         //update the number of redemptions for the promotion code.
         if (Cart66Session::get('Cart66Promotion')) {
             Cart66Session::get('Cart66Promotion')->updateRedemptions();
         }
         // Send email receipts
         if (CART66_PRO && CART66_EMAILS && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
             $notify = new Cart66AdvancedNotifications($order_id);
             $notify->sendAdvancedEmailReceipts();
         } elseif (CART66_EMAILS) {
             $notify = new Cart66Notifications($order_id);
             $notify->sendEmailReceipts();
         }
         //Cart66Common::sendEmailReceipts($order_id);
     }
     // Redirect to receipt page
     $this->goToReceipt($order_id);
 }