/** * 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; } } }
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; } } } }
if (Cart66Common::isHttps()) { $url = preg_replace('/http[s]*:/', 'https:', $url); } else { $url = preg_replace('/http[s]*:/', 'http:', $url); } ?> <input type="hidden" name="lookup-url" id="lookup-url" value="<?php echo $url; ?> " /> <input type="hidden" name="ouid" id="ouid" value="<?php echo Cart66Session::get('Cart66PendingOUID'); ?> " /> <input type="hidden" name="current-page" id="current-page" value="<?php echo Cart66Common::getCurrentPageUrl(); ?> " /> <script type="text/javascript"> (function($){ $(document).ready(function(){ setInterval(function(){ lookUpOrder(); }, 5000); }) function lookUpOrder() { var ajaxurl = $('#lookup-url').val(); var ouid = $('#ouid').val(); var currentPage = $('#current-page').val(); $.ajax({ type: "POST",
public function getLogoutUrl() { $url = Cart66Common::getCurrentPageUrl(); $pgs = get_posts('numberposts=1&post_type=any&meta_key=cart66_member&meta_value=logout'); if (count($pgs)) { $url = get_permalink($pgs[0]->ID); } return $url; }
<a href="http://www.cart66.com/jquery-errors/"><?php _e('Possible solutions', 'cart66'); ?> </a></div> <?php } } $url = Cart66Common::appendWurlQueryString('cart66AjaxCartRequests'); if (Cart66Common::isHttps()) { $url = preg_replace('/http[s]*:/', 'https:', $url); } else { $url = preg_replace('/http[s]*:/', 'http:', $url); } $product_name = str_replace("'", "\\'", $data["product"]->name); $product = array('id' => $id, 'name' => $product_name, 'ajax' => $data['ajax'], 'returnUrl' => Cart66Common::getCurrentPageUrl(), 'addingText' => __('Adding...', 'cart66')); $localized_data = array('youHave' => __('You have', 'cart66'), 'inYourShoppingCart' => __('in your shopping cart', 'cart66'), 'trackInventory' => $trackInventory, 'ajaxurl' => $url); $localized_data['products'][$id] = $product; global $wp_scripts; $data = array(); if (is_object($wp_scripts)) { $data = $wp_scripts->get_data('cart66-library', 'data'); } if (empty($data)) { wp_localize_script('cart66-library', 'C66', $localized_data); } else { if (!is_array($data)) { $data = json_decode(str_replace('var C66 = ', '', substr($data, 0, -1)), true); } foreach ($data['products'] as $product_id => $product) { $localized_data['products'][$product_id] = $product;
<a href="<?php echo $data['url']; ?> &product_url=<?php echo urlencode(Cart66Common::getCurrentPageUrl()); ?> " class="Cart66AddToCart <?php echo $data['class']; ?> "><?php echo $data['text']; ?> </a>
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); } } }
public function getSubscriptionManagementLink($returnUrl = null) { $url = false; if ($this->isSpreedlySubscription()) { if (!isset($returnUrl)) { $returnUrl = '?return_url=' . Cart66Common::getCurrentPageUrl(); } $spreedly = Cart66Setting::getValue('spreedly_shortname'); $url = "https://spreedly.com/{$spreedly}/subscriber_accounts/" . $this->subscriberToken . $returnUrl; } elseif ($this->isPayPalSubscription()) { if ($this->isActive()) { $url = Cart66Common::replaceQueryString('cart66-task=CancelRecurringPaymentsProfile'); } } return $url; }
public function saveTcoOrder() { global $wpdb; // NEW Parse custom value $referrer = false; $ouid = $_POST['custom']; if (strpos($ouid, '|') !== false) { list($ouid, $referrer) = explode('|', $ouid); } $order = new Cart66Order(); $order->loadByOuid($ouid); if ($order->id > 0 && $order->status == 'checkout_pending' && $_POST['total'] == $order->total) { $statusOptions = Cart66Common::getOrderStatusOptions(); $status = $statusOptions[0]; $data = array('bill_first_name' => $_POST['first_name'], 'bill_last_name' => $_POST['last_name'], 'bill_address' => $_POST['street_address'], 'bill_address2' => $_POST['street_address2'], 'bill_city' => $_POST['city'], 'bill_state' => $_POST['state'], 'bill_zip' => $_POST['zip'], 'bill_country' => $_POST['country'], 'email' => $_POST['email'], 'trans_id' => $_POST['order_number'], 'ordered_on' => date('Y-m-d H:i:s', Cart66Common::localTs()), 'status' => $status); // 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 = '" . $_POST['li_0_product_id'] . "'"; $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"); } $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 } wp_redirect(remove_query_arg('listener', Cart66Common::getCurrentPageUrl())); exit; } }