示例#1
0
 public static function ordersPage()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'GET' && Cart66Common::getVal('task') == 'view') {
         $order = new Cart66Order($_GET['id']);
         $view = Cart66Common::getView('admin/order-view.php', array('order' => $order));
     } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('task') == 'resend email receipt') {
         if (CART66_PRO && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
             $notify = new Cart66AdvancedNotifications($_POST['order_id']);
             $notify->sendAdvancedEmailReceipts(false);
         } else {
             $notify = new Cart66Notifications($_POST['order_id']);
             $notify->sendEmailReceipts();
         }
         $order = new Cart66Order($_POST['order_id']);
         $view = Cart66Common::getView('admin/order-view.php', array('order' => $order, 'resend' => true));
     } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('task') == 'reset download amount') {
         $product = new Cart66Product();
         $product->resetDownloadsForDuid($_POST['duid'], $_POST['order_item_id']);
         $order = new Cart66Order($_POST['order_id']);
         $view = Cart66Common::getView('admin/order-view.php', array('order' => $order));
     } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && Cart66Common::getVal('task') == 'delete') {
         $order = new Cart66Order($_GET['id']);
         $order->deleteMe();
         $view = Cart66Common::getView('admin/orders.php');
     } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('remove') && Cart66Common::postVal('remove') != 'all') {
         $order = new Cart66Order($_GET['id']);
         Cart66AdvancedNotifications::removeTrackingNumber($order);
         $order = new Cart66Order($_GET['id']);
         $view = Cart66Common::getView('admin/order-view.php', array('order' => $order));
     } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('remove') == 'all') {
         $order = new Cart66Order($_GET['id']);
         $order->updateTracking(null);
         $order = new Cart66Order($_GET['id']);
         $view = Cart66Common::getView('admin/order-view.php', array('order' => $order));
     } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('task') == 'update order status') {
         $order = new Cart66Order($_POST['order_id']);
         //$order->updateStatus(Cart66Common::postVal('status'));
         //$order->updateNotes($_POST['notes']);
         $data = array('status' => Cart66Common::postVal('status'), 'notes' => Cart66Common::postVal('notes'));
         $order->setData($data);
         $order->save();
         if (Cart66Common::postVal('send_email_status_update') && CART66_PRO) {
             Cart66AdvancedNotifications::addTrackingNumbers($order);
             $status = Cart66Common::postVal('status');
             if (Cart66Setting::getValue('status_options') != null) {
                 $notify = new Cart66AdvancedNotifications($_POST['order_id']);
                 $notify->sendStatusUpdateEmail($status);
             }
         } elseif (CART66_PRO) {
             Cart66AdvancedNotifications::addTrackingNumbers($order);
         }
         $view = Cart66Common::getView('admin/orders.php');
         //$order = new Cart66Order($_POST['order_id']);
         //$view = Cart66Common::getView('admin/order-view.php', array('order'=>$order));
     } else {
         $view = Cart66Common::getView('admin/orders.php');
     }
     echo $view;
 }
 public function productNames()
 {
     $product = new Cart66Product();
     $ids = explode(',', $this->products);
     $selected = array();
     foreach ($ids as $id) {
         $product->load($id);
         $selected[] = array('id' => $id, 'name' => $product->name);
     }
     return $selected;
 }
 public function getPriceDescription()
 {
     $product = new Cart66Product();
     $spreedlyProduct = $product->getOne("where spreedly_subscription_id = {$this->id}");
     if (!empty($spreedlyProduct->priceDescription)) {
         $out = $spreedlyProduct->priceDescription;
     } else {
         $price = $this->price;
         $out = Cart66Common::currency($price) . ' / ' . $this->terms;
         if ($this->hasFreeTrial()) {
             $duration = $this->chargeLaterDurationQuantity . ' ' . $this->chargeLaterDurationUnits;
             $out .= " <span class='Cart66FreePeriod'>(first {$duration} free)</span>";
         }
     }
     return $out;
 }
 /**
  * Return the HTML for rendering the add to cart buton for the given product id
  */
 public static function getCartButton(Cart66Product $product, $attrs)
 {
     $view = "<p>" . __("Could not load product information", "cart66") . "</p>";
     if ($product->id > 0) {
         // Set CSS style if available
         $style = isset($attrs['style']) ? 'style="' . $attrs['style'] . '"' : '';
         $price = '';
         $quantity = isset($attrs['quantity']) ? $attrs['quantity'] : 1;
         $ajax = isset($attrs['ajax']) ? $attrs['ajax'] : 'no';
         $buttonText = isset($attrs['text']) ? $attrs['text'] : __('Add to Cart', 'cart66');
         $showName = isset($attrs['show_name']) ? strtolower($attrs['show_name']) : '';
         $showPrice = isset($attrs['showprice']) ? strtolower($attrs['showprice']) : 'yes';
         $subscription = 0;
         if ($showPrice == 'yes' || $showPrice == 'only') {
             $price = $product->price;
             // Check for subscription pricing
             if ($product->isSubscription()) {
                 if ($product->isPayPalSubscription()) {
                     $subscription = 1;
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Rendering button for PayPal subscription");
                     $sub = new Cart66PayPalSubscription($product->id);
                     $price = $sub->getPriceDescription($sub->offerTrial > 0, '(trial)');
                 } else {
                     $subscription = 2;
                     if ($product->price > 0) {
                         $price .= ' + ' . $product->getRecurringPriceSummary();
                     } else {
                         $price = $product->getRecurringPriceSummary();
                     }
                 }
             } else {
                 $price = $product->getPriceDescription();
             }
         }
         if ($product->isSubscription()) {
             if ($product->isPayPalSubscription()) {
                 $subscription = 1;
             } else {
                 $subscription = 2;
             }
         }
         $gravity_form_id = isset($product->gravity_form_id) ? $product->gravity_form_id : false;
         $data = array('price' => $price, 'is_user_price' => $product->is_user_price, 'min_price' => $product->min_price, 'max_price' => $product->max_price, 'quantity' => $quantity, 'ajax' => $ajax, 'showPrice' => $showPrice, 'showName' => $showName, 'style' => $style, 'buttonText' => $buttonText, 'subscription' => $subscription, 'addToCartPath' => self::getAddToCartImagePath($attrs), 'product' => $product, 'productOptions' => $product->getOptions(), 'gravity_form_id' => $gravity_form_id);
         $view = Cart66Common::getView('views/cart-button.php', $data, true, true);
     }
     return $view;
 }
 protected function _updateQuantitiesFromPost()
 {
     $qtys = Cart66Common::postVal('quantity');
     if (is_array($qtys)) {
         foreach ($qtys as $itemIndex => $qty) {
             $item = $this->getItem($itemIndex);
             if (!is_null($item) && is_object($item) && get_class($item) == 'Cart66CartItem') {
                 if ($qty == 0) {
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Customer specified quantity of 0 - remove item.");
                     $this->removeItem($itemIndex);
                 }
                 if (Cart66Product::confirmInventory($item->getProductId(), $item->getOptionInfo(), $qty)) {
                     $this->setItemQuantity($itemIndex, $qty);
                 } else {
                     $qtyAvailable = Cart66Product::checkInventoryLevelForProduct($item->getProductId(), $item->getOptionInfo());
                     $this->setItemQuantity($itemIndex, $qtyAvailable);
                     if (!Cart66Session::get('Cart66InventoryWarning')) {
                         Cart66Session::set('Cart66InventoryWarning', '');
                     }
                     $inventoryWarning = Cart66Session::get('Cart66InventoryWarning');
                     $inventoryWarning .= '<div class="alert-message alert-error  Cart66Unavailable">' . __("The quantity for", "cart66") . ' ' . $item->getFullDisplayName() . " " . __("could not be changed to", "cart66") . " {$qty} " . __("because we only have", "cart66") . " {$qtyAvailable} " . __("in stock", "cart66") . ".</div>";
                     Cart66Session::set('Cart66InventoryWarning', $inventoryWarning);
                     Cart66Common::log("Quantity available ({$qtyAvailable}) cannot meet desired quantity ({$qty}) for product id: " . $item->getProductId());
                 }
             }
         }
     }
 }
示例#6
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);
 }
 public function gravityFormToCart($entry)
 {
     if (CART66_PRO) {
         $formId = Cart66GravityReader::getGravityFormIdForEntry($entry['id']);
         if ($formId) {
             $productId = Cart66Product::getProductIdByGravityFormId($formId);
             if ($productId > 0) {
                 $product = new Cart66Product($productId);
                 $qty = $product->gravityCheckForEntryQuantity($entry);
                 $options = $product->gravityGetVariationPrices($entry);
                 $productUrl = Cart66Common::getCurrentPageUrl();
                 $cart = Cart66Session::get('Cart66Cart');
                 $item = $cart->addItem($productId, $qty, $options, $entry['id'], $productUrl, false, true);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart Item Value: " . print_r($item, true));
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Should we use the gravity forms price? " . $product->gravity_form_pricing . ' :: Session value: ' . Cart66Session::get('userPrice_' . $product->id));
                 if ($product->gravity_form_pricing == 1) {
                     $price = Cart66GravityReader::getPrice($entry['id']) / $qty;
                     $entry_id = $item->getFirstFormEntryId();
                     $user_price_name = 'userPrice_' . $productId . '_' . $entry_id;
                     Cart66Session::set($user_price_name, $price, true);
                     // Setting the price of a Gravity Forms pricing product
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Using gravity forms pricing for product: Price: {$price} :: Name: " . $product->name . " :: Session variable name: {$user_price_name}");
                 }
                 $cartPage = get_page_by_path('store/cart');
                 $cartPageLink = get_permalink($cartPage->ID);
                 Cart66Session::set('Cart66LastPage', $_SERVER['HTTP_REFERER']);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart66 Session Dump: " . Cart66Session::dump());
                 if (!Cart66Setting::getValue('display_form_entries_before_sale')) {
                     $entry["status"] = 'unpaid';
                 }
                 RGFormsModel::update_lead($entry);
                 $cart->applyAutoPromotions();
                 do_action('cart66_after_add_to_cart', $product, $qty);
                 wp_redirect($cartPageLink);
                 exit;
             }
         }
     }
 }
示例#8
0
<?php

$product = new Cart66Product();
$totalProductCount = count($product->getModelsNoClass());
if (Cart66Setting::getValue('page_product_report')) {
    $productPageInterval = $totalProductCount > 50 ? 25 : 50;
    $productPageInterval = Cart66Setting::getValue('page_product_report_size') ? Cart66Setting::getValue('page_product_report_size') : $productPageInterval;
} else {
    $productPageInterval = $totalProductCount;
}
$productPageInterval = isset($_GET['perpage']) ? $_GET['perpage'] : $productPageInterval;
$productPageStart = isset($_GET['start']) ? $_GET['start'] : 0;
$productPageEnd = isset($_GET['end']) ? $_GET['end'] : $productPageStart + $productPageInterval;
$products = $product->getModels('where id>0', 'order by name', $productPageStart . ',' . $productPageInterval);
if (Cart66Setting::getValue('page_product_report')) {
    echo "<h1>Reports are paged at ";
    echo Cart66Setting::getValue('page_product_report_size') ? Cart66Setting::getValue('page_product_report_size') : 25;
    echo " products per page.</h1>";
}
if (CART66_PRO) {
    if (count($products)) {
        $today = date('m/d/Y', Cart66Common::localTs());
        $salesGrandTotal = 0;
        $incomeGrandTotal = 0;
        ?>
      <table class="Cart66TableMed">
        <tr>
          <th colspan="2"><?php 
        _e('Product Name', 'cart66');
        ?>
</th>
示例#9
0
<?php

$rule = new Cart66ShippingRule();
$method = new Cart66ShippingMethod();
$rate = new Cart66ShippingRate();
$product = new Cart66Product();
$tab = 1;
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    if ($_POST['cart66-action'] == 'save rule') {
        $rule->setData($_POST['rule']);
        $rule->save();
        $rule->clear();
    } elseif ($_POST['cart66-action'] == 'save shipping validation') {
        Cart66Setting::setValue('require_shipping_validation', $_POST['require_shipping_validation']);
        Cart66Setting::setValue('require_shipping_validation_label', $_POST['require_shipping_validation_label']);
    } elseif ($_POST['cart66-action'] == 'save shipping method') {
        if (isset($_POST['shipping_method']['countries'])) {
            foreach ($_POST['shipping_method']['countries'] as $post_country) {
                $post_country = explode('~', $post_country);
                $post_countries[$post_country[0]] = $post_country[1];
            }
            $_POST['shipping_method']['countries'] = serialize($post_countries);
        }
        $method->setData($_POST['shipping_method']);
        $method->save();
        $method->clear();
    } elseif ($_POST['cart66-action'] == 'save product rate') {
        $rate->setData($_POST['rate']);
        $rate->save();
        $rate->clear();
    } elseif ($_POST['cart66-action'] == 'save local pickup info') {
示例#10
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;
 }
示例#11
0
<?php 
if ($data['gravity_form_id'] && CART66_PRO && $data['showPrice'] != 'only') {
    ?>
  <?php 
    if (!$data['product']->isInventoryTracked($data['product']->getInventoryKey())) {
        ?>
    <?php 
        echo do_shortcode("[gravityform id=" . $data['gravity_form_id'] . " ajax=false] ");
        ?>
  <?php 
    } else {
        ?>
    
    <?php 
        if (Cart66Product::checkInventoryLevelForProduct($data['product']->id) == 0) {
            $soldOutLabel = Cart66Setting::getValue('label_out_of_stock') ? strtolower(Cart66Setting::getValue('label_out_of_stock')) : __('out of stock', 'cart66');
            ?>
      
      <div class="alert-message alert-error Cart66Unavailable">
        We're sorry but <?php 
            echo Cart66GravityReader::getFormTitle($data['gravity_form_id']);
            ?>
 is currently <?php 
            echo $soldOutLabel;
            ?>
.
      </div>
      
  <?php 
        }
 public function __construct($id = null)
 {
     $this->_tableName = Cart66Common::getTableName('products');
     parent::__construct($id);
 }
示例#13
0
 } else {
     if (count($errors)) {
         try {
             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;
 /**
  * Save a PayPal IPN order from a Website Payments Pro cart sale.
  *
  * @param array $pp Urldecoded array of IPN key value pairs
  */
 public function saveOrder($pp)
 {
     global $wpdb;
     // NEW Parse custom value
     $referrer = false;
     $ouid = $pp['custom'];
     if (strpos($ouid, '|') !== false) {
         list($ouid, $referrer, $gfData) = explode('|', $ouid);
     }
     $order = new Cart66Order();
     $order->loadByOuid($ouid);
     if ($order->id > 0 && $order->status == 'checkout_pending') {
         $hasDigital = false;
         // Calculate subtotal
         $subtotal = 0;
         $numCartItems = $pp['num_cart_items'] > 0 ? $pp['num_cart_items'] : 1;
         for ($i = 1; $i <= $numCartItems; $i++) {
             // PayPal in not consistent in the way it passes back the item amounts
             $amt = 0;
             if (isset($pp['mc_gross' . $i])) {
                 $amt = $pp['mc_gross' . $i];
             } elseif (isset($pp['mc_gross_' . $i])) {
                 $amt = $pp['mc_gross_' . $i];
             }
             $subtotal += $amt;
         }
         $statusOptions = Cart66Common::getOrderStatusOptions();
         $status = $statusOptions[0];
         // Parse Gravity Forms ids
         $gfIds = array();
         if (!empty($gfData)) {
             $forms = explode(',', $gfData);
             foreach ($forms as $f) {
                 list($itemId, $formEntryId) = explode(':', $f);
                 $gfIds[$itemId] = $formEntryId;
             }
         }
         // Look for discount amount
         $discount = 0;
         if (isset($pp['discount'])) {
             $discount = $pp['discount'];
         }
         $data = array('bill_first_name' => $pp['first_name'], 'bill_last_name' => $pp['last_name'], 'bill_address' => $pp['address_street'], 'bill_city' => $pp['address_city'], 'bill_state' => $pp['address_state'], 'bill_zip' => $pp['address_zip'], 'bill_country' => $pp['address_country'], 'ship_first_name' => $pp['address_name'], 'ship_address' => $pp['address_street'], 'ship_city' => $pp['address_city'], 'ship_state' => $pp['address_state'], 'ship_zip' => $pp['address_zip'], 'ship_country' => $pp['address_country'], 'email' => $pp['payer_email'], 'phone' => $pp['contact_phone'], 'shipping' => $pp['mc_handling'], 'tax' => $pp['tax'], 'subtotal' => $subtotal, 'total' => $pp['mc_gross'], 'discount_amount' => $discount, 'trans_id' => $pp['txn_id'], 'ordered_on' => date('Y-m-d H:i:s', Cart66Common::localTs()), 'status' => $status);
         foreach ($data as $key => $value) {
             $data[$key] = is_null($value) ? '' : $value;
         }
         // Verify the first items in the IPN are for products managed by Cart66. It could be an IPN from some other type of transaction.
         $productsTable = Cart66Common::getTableName('products');
         $orderItemsTable = Cart66Common::getTableName('order_items');
         $sql = "SELECT id from {$productsTable} where item_number = '" . $pp['item_number1'] . "'";
         $productId = $wpdb->get_var($sql);
         if (!$productId) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] about to throw an exception, this is not an IPN that should be managed by cart66 because the item number does not match up");
             throw new Exception("This is not an IPN that should be managed by Cart66");
         }
         // Look for the 100% coupons shipping item and move it back to a shipping costs rather than a product
         if ($data['shipping'] == 0) {
             for ($i = 1; $i <= $numCartItems; $i++) {
                 $itemNumber = strtoupper($pp['item_number' . $i]);
                 if ($itemNumber == 'SHIPPING') {
                     $data['shipping'] = isset($pp['mc_gross_' . $i]) ? $pp['mc_gross_' . $i] : $pp['mc_gross' . $i];
                 }
             }
         }
         $order->setData($data);
         $order->save();
         $orderId = $order->id;
         // Handle email receipts
         if (CART66_PRO && CART66_EMAILS && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
             $notify = new Cart66AdvancedNotifications($orderId);
             $notify->sendAdvancedEmailReceipts();
         } elseif (CART66_EMAILS) {
             $notify = new Cart66Notifications($orderId);
             $notify->sendEmailReceipts();
         }
         // Process affiliate reward if necessary
         if ($referrer && CART66_PRO) {
             Cart66Common::awardCommission($order->id, $referrer);
             // End processing affiliate information
             if (isset($_COOKIE['ap_id']) && $_COOKIE['ap_id']) {
                 setcookie('ap_id', $referrer, time() - 3600, "/");
                 unset($_COOKIE['ap_id']);
             }
             Cart66Session::drop('app_id');
         }
         if (CART66_PRO) {
             // Begin iDevAffiliate Tracking
             if (CART66_PRO && ($url = Cart66Setting::getValue('idevaff_url'))) {
                 require_once CART66_PATH . "/pro/idevaffiliate-award.php";
             }
             // End iDevAffiliate Tracking
         }
     } else {
         $orderTable = Cart66Common::getTableName('orders');
         // Make sure the transaction id is not already in the database
         $sql = "SELECT count(*) as c from {$orderTable} where trans_id=%s";
         $sql = $wpdb->prepare($sql, $pp['txn_id']);
         $count = $wpdb->get_var($sql);
         if ($count < 1) {
             $hasDigital = false;
             // Calculate subtotal
             $subtotal = 0;
             $numCartItems = $pp['num_cart_items'] > 0 ? $pp['num_cart_items'] : 1;
             for ($i = 1; $i <= $numCartItems; $i++) {
                 // PayPal in not consistent in the way it passes back the item amounts
                 $amt = 0;
                 if (isset($pp['mc_gross' . $i])) {
                     $amt = $pp['mc_gross' . $i];
                 } elseif (isset($pp['mc_gross_' . $i])) {
                     $amt = $pp['mc_gross_' . $i];
                 }
                 $subtotal += $amt;
             }
             $statusOptions = Cart66Common::getOrderStatusOptions();
             $status = $statusOptions[0];
             $ouid = md5($pp['txn_id'] . $pp['address_street']);
             // Parse custom value
             $referrer = false;
             $deliveryMethod = $pp['custom'];
             if (strpos($deliveryMethod, '|') !== false) {
                 list($deliveryMethod, $referrer, $gfData, $coupon) = explode('|', $deliveryMethod);
             }
             // Parse Gravity Forms ids
             $gfIds = array();
             if (!empty($gfData)) {
                 $forms = explode(',', $gfData);
                 foreach ($forms as $f) {
                     list($itemId, $formEntryId) = explode(':', $f);
                     $gfIds[$itemId] = $formEntryId;
                 }
             }
             // Look for discount amount
             $discount = 0;
             if (isset($pp['discount'])) {
                 $discount = $pp['discount'];
             }
             // Look for coupon code
             $coupon_code = "none";
             if (isset($coupon) && $coupon != "") {
                 $coupon_code = $coupon;
             }
             $data = array('bill_first_name' => $pp['first_name'], 'bill_last_name' => $pp['last_name'], 'bill_address' => $pp['address_street'], 'bill_city' => $pp['address_city'], 'bill_state' => $pp['address_state'], 'bill_zip' => $pp['address_zip'], 'bill_country' => $pp['address_country'], 'ship_first_name' => $pp['address_name'], 'ship_address' => $pp['address_street'], 'ship_city' => $pp['address_city'], 'ship_state' => $pp['address_state'], 'ship_zip' => $pp['address_zip'], 'ship_country' => $pp['address_country'], 'shipping_method' => $deliveryMethod, 'email' => $pp['payer_email'], 'phone' => $pp['contact_phone'], 'shipping' => $pp['mc_handling'], 'tax' => $pp['tax'], 'subtotal' => $subtotal, 'total' => $pp['mc_gross'], 'coupon' => $coupon_code, 'discount_amount' => $discount, 'trans_id' => $pp['txn_id'], 'ordered_on' => date('Y-m-d H:i:s', Cart66Common::localTs()), 'status' => $status, 'ouid' => $ouid);
             $data = Cart66Common::deNullArrayValues($data);
             // Verify the first items in the IPN are for products managed by Cart66. It could be an IPN from some other type of transaction.
             $productsTable = Cart66Common::getTableName('products');
             $orderItemsTable = Cart66Common::getTableName('order_items');
             $sql = "SELECT id from {$productsTable} where item_number = '" . $pp['item_number1'] . "'";
             $productId = $wpdb->get_var($sql);
             if (!$productId) {
                 throw new Exception("This is not an IPN that should be managed by Cart66");
             }
             // Look for the 100% coupons shipping item and move it back to a shipping costs rather than a product
             if ($data['shipping'] == 0) {
                 for ($i = 1; $i <= $numCartItems; $i++) {
                     $itemNumber = strtoupper($pp['item_number' . $i]);
                     if ($itemNumber == 'SHIPPING') {
                         $data['shipping'] = isset($pp['mc_gross_' . $i]) ? $pp['mc_gross_' . $i] : $pp['mc_gross' . $i];
                     }
                 }
             }
             $wpdb->insert($orderTable, $data);
             $orderId = $wpdb->insert_id;
             $product = new Cart66Product();
             for ($i = 1; $i <= $numCartItems; $i++) {
                 $sql = "SELECT id from {$productsTable} where item_number = '" . $pp['item_number' . $i] . "'";
                 $productId = $wpdb->get_var($sql);
                 if ($productId > 0) {
                     $product->load($productId);
                     // Decrement inventory
                     $info = $pp['item_name' . $i];
                     if (strpos($info, '(') > 0) {
                         $info = strrchr($info, '(');
                         $start = strpos($info, '(');
                         $end = strpos($info, ')');
                         $length = $end - $start;
                         $variation = substr($info, $start + 1, $length - 1);
                         Cart66Common::log("PayPal Variation Information: {$variation}\n{$info}");
                     }
                     $qty = $pp['quantity' . $i];
                     Cart66Product::decrementInventory($productId, $variation, $qty);
                     if ($hasDigital == false) {
                         $hasDigital = $product->isDigital();
                     }
                     // PayPal is not consistent in the way it passes back the item amounts
                     $amt = 0;
                     if (isset($pp['mc_gross' . $i])) {
                         $amt = $pp['mc_gross' . $i];
                     } elseif (isset($pp['mc_gross_' . $i])) {
                         $amt = $pp['mc_gross_' . $i] / $pp['quantity' . $i];
                     }
                     // Look for Gravity Form Entry ID
                     $formEntryId = '';
                     if (is_array($gfIds) && !empty($gfIds) && isset($gfIds[$i])) {
                         $formEntryId = $gfIds[$i];
                         if (class_exists('RGFormsModel')) {
                             if ($lead = RGFormsModel::get_lead($formEntryId)) {
                                 $lead['status'] = 'active';
                                 RGFormsModel::update_lead($lead);
                             }
                         }
                     }
                     $duid = md5($pp['txn_id'] . '-' . $orderId . '-' . $productId);
                     $data = array('order_id' => $orderId, 'product_id' => $productId, 'item_number' => $pp['item_number' . $i], 'product_price' => $amt, 'description' => $pp['item_name' . $i], 'quantity' => $pp['quantity' . $i], 'duid' => $duid, 'form_entry_ids' => $formEntryId);
                     $wpdb->insert($orderItemsTable, $data);
                 }
             }
             // Handle email receipts
             if (CART66_PRO && CART66_EMAILS && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
                 $notify = new Cart66AdvancedNotifications($orderId);
                 $notify->sendAdvancedEmailReceipts();
             } elseif (CART66_EMAILS) {
                 $notify = new Cart66Notifications($orderId);
                 $notify->sendEmailReceipts();
             }
             $promotion = new Cart66Promotion();
             $promotion->loadByCode($coupon_code);
             if ($promotion) {
                 $promotion->updateRedemptions();
             }
             // Process affiliate reward if necessary
             if ($referrer) {
                 Cart66Common::awardCommission($orderId, $referrer);
             }
         }
         // end transaction id check
     }
 }
示例#15
0
    if ($product->loadByDuid($downloadItem->duid) && $product->isDigital()) {
        $hasDigital = true;
    }
}
?>
          <?php 
if ($hasDigital) {
    ?>
      <tr>
        <td valign="top">
            <br /><?php 
    _e('Downloads', 'cart66');
    ?>
:<br />
            <?php 
    $product = new Cart66Product();
    foreach ($order->getItems() as $downloadItem) {
        if ($product->loadByDuid($downloadItem->duid) && $product->isDigital()) {
            $order_item_id = $product->loadItemIdByDuid($downloadItem->duid);
            $downloadTimes = $product->countDownloadsForDuid($downloadItem->duid, $order_item_id);
            ?>
                  <em><?php 
            echo $product->name;
            ?>
: <?php 
            echo $downloadTimes;
            ?>
 <?php 
            _e('out of', 'cart66');
            ?>
 <?php 
 
        <?php 
echo _n('item', 'items', $data['numItems'], 'cart66');
?>
 
        (<?php 
echo Cart66Common::currency($data['cartWidget']->getSubTotal());
?>
) <?php 
_e('in your shopping cart', 'cart66');
?>
.
      </p>
      <?php 
$items = $data['items'];
$product = new Cart66Product();
$subtotal = Cart66Session::get('Cart66Cart')->getSubTotal();
$shippingMethods = Cart66Session::get('Cart66Cart')->getShippingMethods();
$shipping = Cart66Session::get('Cart66Cart')->getShippingCost();
$tax = 0;
if (isset($data['tax']) && $data['tax'] > 0) {
    $tax = $data['tax'];
} else {
    // Check to see if all sales are taxed
    $tax = Cart66Session::get('Cart66Cart')->getTax('All Sales');
}
?>
      <form id='Cart66WidgetCartForm' action="" method="post">
        <input type='hidden' name='task' value='updateCart' />
          <table id='Cart66AdvancedWidgetCartTable' class="Cart66AdvancedWidgetCartTable">
            <?php 
示例#17
0
 /**
  * Return the PayPal subscription id if the product is a PayPal subscription product. 
  * Otherwise return false.
  */
 public function getPayPalSubscriptionId()
 {
     $subId = false;
     $product = new Cart66Product($this->_productId);
     if ($product->isPayPalSubscription()) {
         $subId = $product->id;
         // Note: Products and PayPal subscriptions share the same database table
     }
     return $subId;
 }
示例#18
0
<?php

$items = Cart66Session::get('Cart66Cart')->getItems();
$shippingMethods = Cart66Session::get('Cart66Cart')->getShippingMethods();
$shipping = Cart66Session::get('Cart66Cart')->getShippingCost();
$promotion = Cart66Session::get('Cart66Promotion');
$product = new Cart66Product();
$subtotal = Cart66Session::get('Cart66Cart')->getSubTotal();
$discountAmount = Cart66Session::get('Cart66Cart')->getDiscountAmount();
$cartPage = get_page_by_path('store/cart');
$checkoutPage = get_page_by_path('store/checkout');
$setting = new Cart66Setting();
// Try to return buyers to the last page they were on when the click to continue shopping
if (Cart66Setting::getValue('continue_shopping') == 'store_home') {
    // force the last page to be store home
    $lastPage = Cart66Setting::getValue('store_url') ? Cart66Setting::getValue('store_url') : get_bloginfo('url');
    Cart66Session::set('Cart66LastPage', $lastPage);
} else {
    if (isset($_SERVER['HTTP_REFERER']) && isset($_POST['task']) && $_POST['task'] == "addToCart") {
        $lastPage = $_SERVER['HTTP_REFERER'];
        Cart66Session::set('Cart66LastPage', $lastPage);
    }
    if (!Cart66Session::get('Cart66LastPage')) {
        // If the last page is not set, use the store url
        $lastPage = Cart66Setting::getValue('store_url') ? Cart66Setting::getValue('store_url') : get_bloginfo('url');
        Cart66Session::set('Cart66LastPage', $lastPage);
    }
}
$fullMode = true;
if (isset($data['mode']) && $data['mode'] == 'read') {
    $fullMode = false;
             </tr>
           </table>
           <!-- End Footer -->
         </td>
       </tr>
     </table>
     <!-- End Main Table -->
   </div>
 </body>
 </html>
 <?php 
   } else {
       $msg = __("ORDER NUMBER", "cart66") . ": " . $order->trans_id . "\n\n";
       $msg .= __("Order Status", "cart66") . ": " . str_replace('_', ' ', strtoupper($status)) . "\n\n";
       $hasDigital = false;
       $product = new Cart66Product();
       foreach ($order->getItems() as $item) {
           $product->load($item->product_id);
           if ($hasDigital == false) {
               $hasDigital = $product->isDigital();
           }
           $price = $item->product_price * $item->quantity;
           // $msg .= "Item: " . $item->item_number . ' ' . $item->description . "\n";
           $msg .= __("Item", "cart66") . ": ";
           if (Cart66Setting::getValue('display_item_number_receipt')) {
               $msg .= $item->item_number . ' ';
           }
           $msg .= $item->description . "\n";
           if ($item->quantity > 1) {
               $msg .= __("Quantity", "cart66") . ": " . $item->quantity . "\n";
           }
<?php

$product = new Cart66Product();
$adminUrl = get_bloginfo('wpurl') . '/wp-admin/admin.php';
$errorMessage = false;
if ($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['cart66-action'] == 'save product') {
    $_POST['product']['price'] = isset($_POST['product']['price']) ? Cart66Common::convert_currency_to_number($_POST['product']['price']) : '';
    try {
        $product->handleFileUpload();
        $product->setData(Cart66Common::postVal('product'));
        $product->save();
        $product->clear();
    } catch (Cart66Exception $e) {
        $errorCode = $e->getCode();
        if ($errorCode == 66102) {
            // Product save failed
            $errors = $product->getErrors();
            $errorMessage = Cart66Common::showErrors($errors, "<p><b>" . __("The product could not be saved for the following reasons", "cart66") . ":</b></p>");
        } elseif ($errorCode == 66101) {
            // File upload failed
            $errors = $product->getErrors();
            $errorMessage = Cart66Common::showErrors($errors, "<p><b>" . __("The file upload failed", "cart66") . ":</b></p>");
        }
        Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Product save failed ({$errorCode}): " . strip_tags($errorMessage));
    }
} elseif (isset($_GET['task']) && $_GET['task'] == 'edit' && isset($_GET['id']) && $_GET['id'] > 0) {
    $id = Cart66Common::getVal('id');
    $product->load($id);
} elseif (isset($_GET['task']) && $_GET['task'] == 'delete' && isset($_GET['id']) && $_GET['id'] > 0) {
    $id = Cart66Common::getVal('id');
    $product->load($id);
示例#21
0
<h2><?php 
_e('Cart66 Inventory Tracking', 'cart66');
?>
</h2>

<?php 
// Get a list of all products
$product = new Cart66Product();
$products = $product->getModels('where id>0', 'order by name', '1');
$save = false;
if ($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['cart66-task'] == 'save-inventory-form') {
    $save = true;
    $product->updateInventoryFromPost($_REQUEST);
    ?>
  <script type="text/javascript">
    (function($){
      $(document).ready(function(){
        $("#Cart66SuccessBox").show().delay(1000).fadeOut('slow'); 
      })
    })(jQuery);
  </script> 
  <div id='Cart66SuccessBox' style='width: 300px;'><p class='alert-message success'><?php 
    _e('Inventory updated', 'cart66');
    ?>
</p></div>
  <?php 
}
$setting = new Cart66Setting();
$track = Cart66Setting::getValue('track_inventory');
$wpurl = get_bloginfo('wpurl');
if (CART66_PRO) {
    }
    // End processing affiliate information
    // Begin iDevAffiliate Tracking
    if (CART66_PRO && ($url = Cart66Setting::getValue('idevaff_url'))) {
        require_once CART66_PATH . "/pro/idevaffiliate-award.php";
    }
    // End iDevAffiliate Tracking
    if (isset($_COOKIE['ap_id']) && $_COOKIE['ap_id']) {
        setcookie('ap_id', $referrer, time() - 3600, "/");
        unset($_COOKIE['ap_id']);
    }
    Cart66Session::drop('app_id');
}
if (isset($_GET['duid'])) {
    $duid = $_GET['duid'];
    $product = new Cart66Product();
    if ($product->loadByDuid($duid)) {
        $okToDownload = true;
        if ($product->download_limit > 0) {
            // Check if download limit has been exceeded
            $order_item_id = $product->loadItemIdByDuid($duid);
            if ($product->countDownloadsForDuid($duid, $order_item_id) >= $product->download_limit) {
                $okToDownload = false;
            }
        }
        if ($okToDownload) {
            $data = array('duid' => $duid, 'downloaded_on' => date('Y-m-d H:i:s'), 'ip' => $_SERVER['REMOTE_ADDR'], 'order_item_id' => $product->loadItemIdByDuid($duid));
            $downloadsTable = Cart66Common::getTableName('downloads');
            $wpdb->insert($downloadsTable, $data, array('%s', '%s', '%s', '%s'));
            $setting = new Cart66Setting();
            if (!empty($product->s3Bucket) && !empty($product->s3File)) {
               </tr>
             </table>
             <!-- End Footer -->
             
           </td>
         </tr>
       </table>
       <!-- End Main Table -->
     </div>
   </body>
   </html>
 <?php 
   } else {
       $msg = __("ORDER NUMBER", "cart66") . ": " . $order->trans_id . "\n\n";
       foreach ($order->getItems() as $item) {
           $product = new Cart66Product();
           $product->load($item->product_id);
           $fulfillmentProducts = explode(',', $orderFulfillment->products);
           foreach ($fulfillmentProducts as $prod) {
               if ($prod == $item->product_id) {
                   if (Cart66Setting::getValue('display_item_number_receipt')) {
                       $msg .= $item->item_number . ' ';
                   }
                   $msg .= "<b>" . $item->description . "</b>\n";
                   $msg .= __('Quantity: ', 'cart66') . $item->quantity . "\n";
                   if (!empty($item->form_entry_ids)) {
                       $entries = explode(',', $item->form_entry_ids);
                       foreach ($entries as $entryId) {
                           if (class_exists('RGFormsModel')) {
                               if (RGFormsModel::get_lead($entryId)) {
                                   echo Cart66GravityReader::displayGravityForm($entryId, true, true);
示例#24
0
 public function drawFeatureLevelMetaBox($post)
 {
     if (CART66_PRO) {
         $plans = array();
         $featureLevels = array();
         $data = array();
         // Load feature levels defined in Spreedly if available
         if (class_exists('SpreedlySubscription')) {
             $sub = new SpreedlySubscription();
             $subs = $sub->getSubscriptions();
             foreach ($subs as $s) {
                 // $plans[] = array('feature_level' => (string)$s->featureLevel, 'name' => (string)$s->name);
                 $plans[(string) $s->name] = (string) $s->featureLevel;
                 $featureLevels[] = (string) $s->featureLevel;
             }
         }
         // Load feature levels defined in PayPal subscriptions
         $sub = new Cart66PayPalSubscription();
         $subs = $sub->getSubscriptionPlans();
         foreach ($subs as $s) {
             $plans[$s->name] = $s->featureLevel;
             $featureLevels[] = $s->featureLevel;
         }
         // Load feature levels defined in Membership products
         foreach (Cart66Product::getMembershipProducts() as $membership) {
             $plans[$membership->name] = $membership->featureLevel;
             $featureLevels[] = $membership->featureLevel;
         }
         // Put unique feature levels in alphabetical order
         if (count($featureLevels)) {
             $featureLevels = array_unique($featureLevels);
             sort($featureLevels);
             $savedPlanCsv = get_post_meta($post->ID, '_cart66_subscription', true);
             $savedFeatureLevels = empty($savedPlanCsv) ? array() : explode(',', $savedPlanCsv);
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart66 Saved Plans: {$savedPlanCsv} -- " . print_r($savedFeatureLevels, true));
             $data = array('featureLevels' => $featureLevels, 'plans' => $plans, 'saved_feature_levels' => $savedFeatureLevels);
         }
         $box = Cart66Common::getView('pro/views/feature-level-meta-box.php', $data);
         echo $box;
     }
 }
 public static function spreedlyTable()
 {
     $columns = array('id', 'item_number', 'name', 'price', 'taxable', 'shipped');
     $indexColumn = "id";
     $tableName = Cart66Common::getTableName('products');
     $where = self::dataTablesWhere($columns);
     $limit = self::dataTablesLimit() == '' ? null : self::dataTablesLimit();
     $order = self::dataTablesOrder($columns);
     if ($where == null) {
         $where = "where spreedly_subscription_id > 0";
     } else {
         $where .= " AND spreedly_subscription_id > 0";
     }
     $iTotal = self::totalRows($indexColumn, $tableName, $where);
     $iFilteredTotal = self::filteredRows($indexColumn, $tableName, $where);
     $data = array();
     $spreedly = new Cart66Product();
     $spreedlys = $spreedly->getSpreedlyProducts($where, $order, $limit);
     foreach ($spreedlys as $s) {
         $gfTitles = self::gfData();
         if ($s->gravityFormId > 0 && isset($gfTitles) && isset($gfTitles[$s->gravityFormId])) {
             $gfTitles = '<br/><em>Linked To Gravity Form: ' . $gfTitles[$s->gravityFormId] . '</em>';
         } else {
             $gfTitles = '';
         }
         $data[] = array($s->id, $s->item_number, $s->name . $gfTitles, $s->getPriceDescription(), $s->taxable ? ' Yes' : 'No', $s->shipped ? ' Yes' : 'No');
     }
     $array = array('sEcho' => $_GET['sEcho'], 'iTotalRecords' => $iTotal[0], 'iTotalDisplayRecords' => $iFilteredTotal[0], 'aaData' => $data);
     echo json_encode($array);
     die;
 }
 public static function checkInventoryOnAddToCart()
 {
     $result = array(true);
     $itemId = Cart66Common::postVal('cart66ItemId');
     $options = '';
     $optionsMsg = '';
     $opt1 = Cart66Common::postVal('options_1');
     $opt2 = Cart66Common::postVal('options_2');
     if (!empty($opt1)) {
         $options = $opt1;
         $optionsMsg = trim(preg_replace('/\\s*([+-])[^$]*\\$.*$/', '', $opt1));
     }
     if (!empty($opt2)) {
         $options .= '~' . $opt2;
         $optionsMsg .= ', ' . trim(preg_replace('/\\s*([+-])[^$]*\\$.*$/', '', $opt2));
     }
     $scrubbedOptions = Cart66Product::scrubVaritationsForIkey($options);
     if (!Cart66Product::confirmInventory($itemId, $scrubbedOptions)) {
         $result[0] = false;
         $p = new Cart66Product($itemId);
         $counts = $p->getInventoryNamesAndCounts();
         $out = '';
         if (count($counts)) {
             $out = '<table class="inventoryCountTableModal">';
             $out .= '<tr><td colspan="2"><strong>' . __('Currently In Stock', 'cart66') . '</strong></td></tr>';
             foreach ($counts as $name => $qty) {
                 $out .= '<tr>';
                 $out .= "<td>{$name}</td><td>{$qty}</td>";
                 $out .= '</tr>';
             }
             $out .= '</table>';
         }
         $soldOutLabel = Cart66Setting::getValue('label_out_of_stock') ? strtolower(Cart66Setting::getValue('label_out_of_stock')) : __('out of stock', 'cart66');
         $result[1] = $p->name . " " . $optionsMsg . " is {$soldOutLabel} {$out}";
     }
     $result = json_encode($result);
     echo $result;
     die;
 }
示例#27
0
 /**
  * Check to see if the order includes a product that requires an account and if there is an account in the system
  *
  * Return values:
  *   1 = The account exists
  *   0 = There is no account associated with the order and there is no need for one
  *  -1 = There is no account associated with the order but there should be
  *
  * @return int
  */
 public function hasAccount()
 {
     if ($this->id == 0 || empty($this->id)) {
         throw new Cart66Exception(66400, 'Cannot get account status on an order with no order id');
     }
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Account ID on order: " . $this->account_id);
     if ($this->account_id > 0) {
         return 1;
         // The order has an account associated with it
     } else {
         // No account exists for this order, but does it need one?
         $product = new Cart66Product();
         $items = $this->getItems();
         foreach ($items as $item) {
             $product->load($item->product_id);
             if ($product->isMembershipProduct() || $product->isSubscription()) {
                 return -1;
                 // No account exists but there should be one
             }
         }
     }
     return 0;
     // No account exists and none is needed.
 }
示例#28
0
            <?php 
}
?>
          </ul>
          
          <ul style="float: left;">
            <li>
              <label class="med" for="plan-product_id"><?php 
_e('Product', 'cart66');
?>
:</label>
              <select style="width: 375px;" name="plan[product_id]" id="plan-product_id">
                <option value="">Select a Membership or Subscription Product</option>
                <?php 
$membership_products = Cart66Product::getMembershipProducts();
$subscription_products = Cart66Product::getSubscriptionProducts(" WHERE spreedly_subscription_id=NULL OR spreedly_subscription_id=0");
$products_than_need_an_account = array_merge($membership_products, $subscription_products);
if (!empty($products_than_need_an_account)) {
    foreach ($products_than_need_an_account as $member_product) {
        ?>
                    <option value="<?php 
        echo $member_product->id;
        ?>
"><?php 
        echo $member_product->name;
        ?>
 (<?php 
        echo $member_product->feature_level;
        ?>
)</option>
                    <?php 
示例#29
0
        _e("Please set up your products in the", "cart66");
        ?>
 <a href="admin.php?page=cart66-products"><?php 
        _e("Cart66 Products", "cart66");
        ?>
</a> <?php 
        _e("page before configuring these email notifications", "cart66");
        ?>
.</h3>
      <?php 
    }
    ?>
    </div>
    <div id="notifications-reminder_settings" class="pane">
      <?php 
    $subscriptions = Cart66Product::loadProductsOutsideOfClass('id, name, item_number', 'is_membership_product = 1 OR is_paypal_subscription = 1 OR spreedly_subscription_id > 0');
    if (!empty($subscriptions)) {
        ?>
        <h3><?php 
        _e('Subscription Reminders', 'cart66');
        ?>
</h3>
        <p class="description"><?php 
        _e('This section allows you to send reminder renewal emails based on subscriptions that have been purchased.', 'cart66');
        ?>
</p>
        <form action="" method="post">
          <input type="hidden" name="cart66-action" value="save reminder" />
          <input type="hidden" name="reminder[id]" value="<?php 
        echo $reminder->id;
        ?>
<?php

$product = new Cart66Product();
$order = $data['order'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title><?php 
_e('Your Receipt', 'cart66');
?>
</title>
	<style type="text/css" media="print">
/*<![CDATA[*/
	 #print_button {
	   display: none;
	 }
/*]]>*/
	</style>
	<style type="text/css" media="screen,print">
  /*<![CDATA[*/
     body {
       font-family: arial;     
       font-size: 12px;      
       color: black;   
     }       
     table {