Esempio n. 1
0
 public function initCheckout($total, $override = false)
 {
     if (isset($_POST['cart66-task']) && $_POST['cart66-task'] == '2checkout' || $override) {
         $pendingOrderId = $this->storePendingOrder();
         $order = new Cart66Order($pendingOrderId);
         Cart66Session::set('Cart66PendingOUID', $order->ouid);
         $redirect = $this->get_redirect_url();
         if (Cart66Setting::getValue('tco_test_mode')) {
             $redirect .= '&demo=Y';
         }
         // Start affiliate program integration
         $aff = '';
         if (Cart66Session::get('ap_id')) {
             $aff .= Cart66Session::get('ap_id');
         } elseif (isset($_COOKIE['ap_id'])) {
             $aff .= $_COOKIE['ap_id'];
         }
         // End affilitate program integration
         $redirect .= '&custom=' . $order->ouid . '|' . $aff . '|';
         // Redirect to 2Checkout
         //print_r($redirect);
         wp_redirect($redirect);
         exit;
     }
 }
Esempio n. 2
0
 /**
  * Login to a Cart66 account by placing the Cart66AccountId into the session.
  * If login is successful the object is loaded from the database.
  * 
  * @param string $email Account holder's email address
  * @param string $password Account holder's plain text password (not yet encrypted)
  * @return integer The account id or NULL if no account id is found
  */
 public function login($email, $password)
 {
     $accountsTable = Cart66Common::getTableName('accounts');
     $sql = "SELECT id from {$accountsTable} where username = %s and password = %s";
     $sql = $this->_db->prepare($sql, $email, md5($password));
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Login query: {$sql}");
     if ($accountId = $this->_db->get_var($sql)) {
         Cart66Session::set('Cart66AccountId', $accountId);
         $this->load($accountId);
     }
     return $accountId;
 }
 /**
  * If the visitor is not a logged in, check if the page that is being accessed is private. 
  * If so, redirect to the login page or the access denied page. 
  */
 public static function verifyPageAccessRights($pageId)
 {
     if (!Cart66Common::isLoggedIn()) {
         $privatePages = self::getPrivatePageIds();
         $deniedLink = self::getDeniedLink();
         if (in_array($pageId, $privatePages)) {
             Cart66Session::set('Cart66AccessDeniedRedirect', Cart66Common::getCurrentPageUrl());
             wp_redirect($deniedLink);
             exit;
         }
     }
 }
Esempio n. 4
0
        protected function _buildCheckoutView($gateway)
        {
            $ssl = Cart66Setting::getValue('auth_force_ssl');
            if ($ssl) {
                if (!Cart66Common::isHttps()) {
                    $sslUrl = "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
                    wp_redirect($sslUrl);
                    exit;
                }
            }
            // use manual gateway form to gather user information
            require_once CART66_PATH . "/gateways/Cart66ManualGateway.php";
            $gateway = new Cart66_paymill_for_wordpress();
            if (!Cart66Session::get('Cart66Cart')) {
                Cart66Session::set('Cart66Cart', new Cart66Cart());
            }
            if (!$GLOBALS['paymill_active']) {
                paymill_load_frontend_scripts();
                // load frontend scripts
                // settings
                $GLOBALS['paymill_active'] = true;
                $cart_total = intval(Cart66Session::get('Cart66Cart')->getGrandTotal(false) * 100);
                $currency = CURRENCY_CODE;
                $no_logos = false;
                ob_start();
                // form ids
                echo '<script>
				paymill_form_checkout_id = "#Cart66_paymill_for_wordpress_form";
				paymill_form_checkout_submit_id = "#Cart66CheckoutButton";
				paymill_shop_name = "cart66";
				paymill_pcidss3 = ' . (empty($GLOBALS['paymill_settings']->paymill_general_settings['pci_dss_3']) || $GLOBALS['paymill_settings']->paymill_general_settings['pci_dss_3'] != '1' ? 1 : 0) . ';
				paymill_pcidss3_lang = "' . substr(apply_filters('plugin_locale', get_locale(), $domain), 0, 2) . '";
				</script>
				';
                require_once PAYMILL_DIR . 'lib/tpl/checkout_form.php';
                $view .= '<h2>' . __('Payment Information', 'paymill') . '</h2>';
                $view .= ob_get_clean();
                $checkout = Cart66Common::getView('views/checkout.php', array('gateway' => $gateway), true, true);
                $view .= str_replace(array('Cart66ManualGateway', 'Payment Information'), array('Cart66_paymill_for_wordpress', 'Contact Information'), $checkout);
            } else {
                $view = '<div class="paymill_notification paymill_notification_once_only"><strong>Error:</strong> Paymill can be loaded once only on the same page.</div>';
            }
            return $view;
        }
 public function widget($args, $instance)
 {
     extract($args);
     $data['title'] = $instance['title'];
     $data['shipping'] = isset($instance['shipping']) ? $instance['shipping'] : false;
     if (!Cart66Session::get('Cart66Cart')) {
         Cart66Session::set('Cart66Cart', new Cart66Cart());
     }
     $this->_items = Cart66Session::get('Cart66Cart')->getItems();
     $data['items'] = $this->_items;
     $data['cartPage'] = get_page_by_path('store/cart');
     $data['checkoutPage'] = get_page_by_path('store/checkout');
     $data['numItems'] = $this->countItems();
     $data['cartWidget'] = $this;
     $data['beforeWidget'] = $before_widget;
     $data['afterWidget'] = $after_widget;
     $data['beforeTitle'] = $before_title;
     $data['afterTitle'] = $after_title;
     if (isset($instance['standard_advanced']) && $instance['standard_advanced'] == 'advanced') {
         echo Cart66Common::getView('views/cart-sidebar-advanced.php', $data);
     } else {
         echo Cart66Common::getView('views/cart-sidebar.php', $data);
     }
 }
 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;
             }
         }
     }
 }
    Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Setting Payment Details:\n" . print_r($payment, true));
    $pp->setPaymentDetails($payment);
    // Add cart items to PayPal
    $pp->populatePayPalCartItems();
    // Set Express Checkout URLs
    $returnPage = get_page_by_path('store/express');
    $returnUrl = get_permalink($returnPage->ID);
    $cancelPage = get_page_by_path('store/checkout');
    $cancelUrl = get_permalink($cancelPage->ID);
    $localeCode = Cart66Common::getLocaleCode();
    $ecUrls = array('RETURNURL' => $returnUrl, 'CANCELURL' => $cancelUrl, 'LOCALECODE' => $localeCode);
    $pp->setEcUrls($ecUrls);
    $response = $pp->SetExpressCheckout();
    $ack = strtoupper($response['ACK']);
    if ('SUCCESS' == $ack || 'SUCCESSWITHWARNING' == $ack) {
        Cart66Session::set('PayPalProToken', $response['TOKEN']);
        $expressCheckoutUrl = $pp->getExpressCheckoutUrl($response['TOKEN']);
        wp_redirect($expressCheckoutUrl);
        exit;
    } elseif (empty($ack)) {
        echo '<pre>Failed to connect via curl to PayPal. The most likely cause is that your PHP installation failed to verify that the CA cert is OK</pre>';
    } else {
        try {
            throw new Cart66Exception(ucwords($response['L_SHORTMESSAGE0']), 66503);
        } catch (Cart66Exception $e) {
            $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage(), array('Error Number: ' . $response['L_ERRORCODE0'], $response['L_LONGMESSAGE0']));
            echo Cart66Common::getView('views/error-messages.php', $exception);
        }
    }
}
?>
Esempio n. 8
0
 $accountId = 0;
 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Should an account be created? " . print_r($createAccount));
 if ($createAccount) {
     $account->save();
     $accountId = $account->id;
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Just created account with id: accountId");
 }
 if ($mp = Cart66Session::get('Cart66Cart')->getMembershipProduct()) {
     $account->attachMembershipProduct($mp, $account->firstName, $account->lastName);
     $accountId = $account->id;
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Attached membership to account id: {$accountId}");
 }
 // Save the order locally
 $orderId = $gateway->saveOrder($total, $tax, $transactionId, $status, $accountId);
 Cart66Session::drop('Cart66SubscriberToken');
 Cart66Session::set('order_id', $orderId);
 Cart66Session::drop('Cart66ProRateAmount');
 $receiptLink = Cart66Common::getPageLink('store/receipt');
 $newOrder = new Cart66Order($orderId);
 // Send 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();
 }
 // Send buyer to receipt page
 $receiptVars = strpos($receiptLink, '?') ? '&' : '?';
 $receiptVars .= "ouid=" . $newOrder->ouid;
 wp_redirect($receiptLink . $receiptVars);
 public static function ajaxTaxUpdate()
 {
     if (isset($_POST['state']) && isset($_POST['state_text']) && isset($_POST['zip']) && isset($_POST['gateway'])) {
         $gateway = Cart66Ajax::loadAjaxGateway($_POST['gateway']);
         $gateway->setShipping(array('state_text' => $_POST['state_text'], 'state' => $_POST['state'], 'zip' => $_POST['zip']));
         $s = $gateway->getShipping();
         if ($s['state'] && $s['zip']) {
             $id = 1;
             $taxLocation = $gateway->getTaxLocation();
             $tax = $gateway->getTaxAmount();
             $rate = $gateway->getTaxRate();
             $total = Cart66Session::get('Cart66Cart')->getGrandTotal() + $tax;
             Cart66Session::set('Cart66Tax', $tax);
             Cart66Session::set('Cart66TaxRate', Cart66Common::tax($rate));
         } else {
             $id = 0;
             $tax = 0;
             $rate = 0;
             $total = Cart66Session::get('Cart66Cart')->getGrandTotal() + $tax;
             Cart66Session::set('Cart66Tax', $tax);
             Cart66Session::set('Cart66TaxRate', Cart66Common::tax($rate));
         }
         if (Cart66Session::get('Cart66Cart')->getTax('All Sales')) {
             $rate = $gateway->getTaxRate();
             Cart66Session::set('Cart66TaxRate', Cart66Common::tax($rate));
         }
     }
     $result = array('id' => $id, 'state' => $s['state'], 'zip' => $s['zip'], 'tax' => Cart66Common::currency($tax), 'rate' => $rate == 0 ? '0.00%' : Cart66Common::tax($rate), 'total' => Cart66Common::currency($total));
     echo json_encode($result);
     die;
 }
Esempio n. 10
0
            ?>
" class="Cart66ButtonSecondary Cart66CartContinueShopping" title="Continue Shopping"><?php 
            _e('Continue Shopping', 'cart66');
            ?>
</a>
        <?php 
        }
        ?>
	</div>

	
	  <?php 
        // dont show checkout until terms are accepted (if necessary)
        if (Cart66Setting::getValue('require_terms') != 1 || Cart66Setting::getValue('require_terms') == 1 && (isset($_POST['terms_acceptance']) || Cart66Session::get("terms_acceptance") == "accepted")) {
            if (Cart66Setting::getValue('require_terms') == 1) {
                Cart66Session::set("terms_acceptance", "accepted", true);
            }
            ?>
        <?php 
            $checkoutImg = false;
            if ($cartImgPath) {
                $checkoutImg = $cartImgPath . 'checkout.png';
            }
            ?>
        <?php 
            if (number_format(Cart66Setting::getValue('minimum_amount'), 2, '.', '') > number_format(Cart66Session::get('Cart66Cart')->getSubTotal(), 2, '.', '') && Cart66Setting::getValue('minimum_cart_amount') == 1) {
                ?>
        <?php 
            } else {
                ?>
      <div id="checkoutShopping">
Esempio n. 11
0
        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;
            }
        }
    }
}
$cartImgPath = Cart66Setting::getValue('cart_images_url');
if ($cartImgPath) {
    if (strpos(strrev($cartImgPath), '/') !== 0) {
        $cartImgPath .= '/';
    }
    $createAccountImgPath = $cartImgPath . 'create-account.png';
}
Esempio n. 12
0
 public function protectSubscriptionPages()
 {
     global $wp_query;
     // Keep visitors who are not logged in from seeing private pages
     if (!isset($wp_query->tax_query)) {
         $pid = isset($wp_query->post->ID) ? $wp_query->post->ID : NULL;
         Cart66AccessManager::verifyPageAccessRights($pid);
         // block subscription pages from non-subscribers
         $accountId = Cart66Common::isLoggedIn() ? Cart66Session::get('Cart66AccountId') : 0;
         $account = new Cart66Account($accountId);
         // Get a list of the required subscription ids
         $requiredFeatureLevels = Cart66AccessManager::getRequiredFeatureLevelsForPage($pid);
         if (count($requiredFeatureLevels)) {
             // Check to see if the logged in user has one of the required subscriptions
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] protectSubscriptionPages: Page access looking for " . $account->getFeatureLevel() . " in: " . print_r($requiredFeatureLevels, true));
             if (!in_array($account->getFeatureLevel(), $requiredFeatureLevels) || !$account->isActive()) {
                 Cart66Session::set('Cart66AccessDeniedRedirect', Cart66Common::getCurrentPageUrl());
                 wp_redirect(Cart66AccessManager::getDeniedLink());
                 exit;
             }
         }
     } else {
         $exclude = false;
         $meta_query = array();
         //echo nl2br(print_r($wp_query->posts, true));
         foreach ($wp_query->posts as $index => $p) {
             $pid = isset($p->ID) ? $p->ID : NULL;
             // block subscription pages from non-subscribers
             $accountId = Cart66Common::isLoggedIn() ? Cart66Session::get('Cart66AccountId') : 0;
             $account = new Cart66Account($accountId);
             // Get a list of the required subscription ids
             $requiredFeatureLevels = Cart66AccessManager::getRequiredFeatureLevelsForPage($pid);
             if (count($requiredFeatureLevels)) {
                 // Check to see if the logged in user has one of the required subscriptions
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] protectSubscriptionPages: Page access looking for " . $account->getFeatureLevel() . " in: " . print_r($requiredFeatureLevels, true));
                 if (!in_array($account->getFeatureLevel(), $requiredFeatureLevels) || !$account->isActive()) {
                     $exclude = false;
                     if (!Cart66Setting::getValue('remove_posts_from_taxonomy')) {
                         // Set message for when visitor is not logged in
                         if (!($message = Cart66Setting::getValue('post_not_logged_in'))) {
                             $message = __("You must be logged in to view this", "cart66") . " " . $p->post_type . ".";
                         }
                         if (Cart66Common::isLoggedIn()) {
                             // Set message for insuficient access rights
                             if (!($message = Cart66Setting::getValue('post_access_denied'))) {
                                 $message = __("Your current subscription does not allow you to view this", "cart66") . " " . $p->post_type . ".";
                             }
                         }
                         $p->post_content = $message;
                         $p->comment_status = 'closed';
                     } else {
                         $exclude = true;
                     }
                 }
             }
         }
         if ($exclude) {
             global $wpdb;
             $post_id = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_cart66_subscription'");
             $args = array('post__not_in' => $post_id);
             $args = array_merge($args, $wp_query->query);
             query_posts($args);
         }
     }
 }
 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());
                 }
             }
         }
     }
 }
Esempio n. 14
0
<!-- PayPal Checkout -->
<?php 
if (isset($_POST['cmd'])) {
    $paypalAction = 'https://www.paypal.com/cgi-bin/webscr';
    if (SANDBOX) {
        $paypalAction = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
    }
    // store pending order with all information, then send to paypal at the above address via curl... so as to keep all the post data
    require_once CART66_PATH . "/gateways/Cart66PayPalStandard.php";
    $paypalStandard = new Cart66PayPalStandard();
    $pendingOrderId = $paypalStandard->storePendingOrder();
    $order = new Cart66Order($pendingOrderId);
    $_POST['custom'] = $order->ouid . $_POST['custom'];
    Cart66Session::set('Cart66PendingOUID', $order->ouid);
    wp_redirect($paypalAction . '?' . http_build_query($_POST, '', '&'));
    exit;
}
$taxRate = new Cart66TaxRate();
$items = Cart66Session::get('Cart66Cart')->getItems();
$shipping = Cart66Session::get('Cart66Cart')->getShippingCost();
$shippingMethod = Cart66Session::get('Cart66Cart')->getShippingMethodName();
$setting = new Cart66Setting();
$paypalEmail = Cart66Setting::getValue('paypal_email');
if (!$paypalEmail) {
    throw new Cart66Exception('Invalid PayPal Standard Configuration', 66504);
}
$returnUrl = Cart66Setting::getValue('paypal_return_url');
$promotion = Cart66Session::get('Cart66Promotion');
$checkoutOk = true;
if (Cart66Session::get('Cart66Cart')->requireShipping()) {
    $liveRates = Cart66Setting::getValue('use_live_rates');
 /**
  * Return information about pro-rated credit or false if there is none.
  * 
  * Returns a standard object:
  *   $data->description = The description of the credit
  *   $data->amount = The monetary amount of the credit
  *   $data->money = The formated monetary amount of the credit
  * 
  * return object or false
  */
 public function getProRateInfo()
 {
     $data = false;
     $proRateAmount = 0;
     if ($this->isSpreedlySubscription()) {
         if (Cart66Common::isLoggedIn() && Cart66Session::get('Cart66Cart')) {
             if ($subscriptionId = Cart66Session::get('Cart66Cart')->getSpreedlySubscriptionId()) {
                 try {
                     $invoiceData = array('subscription-plan-id' => $subscriptionId, 'subscriber' => array('customer-id' => Cart66Session::get('Cart66AccountId')));
                     $invoice = new SpreedlyInvoice();
                     $invoice->createFromArray($invoiceData);
                     $this->_creditAmount = abs((double) $invoice->invoiceData->{'line-items'}->{'line-item'}[1]->amount);
                     $data = new stdClass();
                     $data->description = $invoice->invoiceData->{'line-items'}->{'line-item'}[1]->description;
                     $data->amount = $this->_creditAmount;
                     $data->money = Cart66Common::currency($this->_creditAmount);
                     if ($data->amount > 0) {
                         $proRateAmount = $data->amount;
                     }
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Spreedly Invoice: " . print_r($invoice->invoiceData, true));
                 } catch (SpreedlyException $e) {
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Unable to locate spreedly customer: " . Cart66Session::get('Cart66AccountId'));
                 }
             }
         }
     }
     Cart66Session::set('Cart66ProRateAmount', $proRateAmount, true);
     return $data;
 }