public static function logout($redirectUrl = null) { if (Cart66Session::get('Cart66AccountId')) { Cart66Session::drop('Cart66AccountId'); Cart66Session::drop('Cart66AccessDeniedRedirect'); Cart66Session::drop('Cart66ProRateAmount'); if (isset($redirectUrl)) { $url = str_replace('cart66-task=logout', '', $redirectUrl); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Redirecting after logout to: {$url}"); wp_redirect($url); exit; } } }
public function accountLogin($attrs) { $account = new Cart66Account(); if ($accountId = Cart66Common::isLoggedIn()) { $account->load($accountId); } $data = array('account' => $account); // Look for password reset task if (isset($_POST['cart66-task']) && $_POST['cart66-task'] == 'account-reset') { $data['resetResult'] = $account->passwordReset(); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Attempted to reset password: "******"] Account Login: "******"] Redirecting after login to: {$url}"); Cart66Session::drop('Cart66AccessDeniedRedirect'); wp_redirect($url); exit; } else { $view .= "<p class='Cart66Error'>Login failed</p>"; } } return $view; }
?> <!-- Begin Newsletter Signup Form --> <?php include CART66_PATH . '/views/newsletter-signup.php'; ?> <!-- End Newsletter Signup Form --> <?php // Erase the shopping cart from the session at the end of viewing the receipt Cart66Session::drop('Cart66Cart'); Cart66Session::drop('PayPalProToken'); Cart66Session::drop('Cart66Tax'); Cart66Session::drop('Cart66Promotion'); Cart66Session::drop('terms_acceptance'); Cart66Session::drop('Cart66ShippingCountryCode'); ?> <?php } else { ?> <p><?php _e('Receipt not available', 'cart66'); ?> </p> <?php } ?> <?php if ($order !== false) {
$gatewayResponse = $gateway->getTransactionResponseDescription(); $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage(), array('error_code' => 'Error: ' . $gatewayResponse['errorcode'], strtolower($gatewayResponse['errormessage']))); echo Cart66Common::getView('views/error-messages.php', $exception); } //$errors['Could Not Process Transaction'] = $gateway->getTransactionResponseDescription(); } } } } // End if supported gateway } // End if POST // Show inventory warning if there is one if (Cart66Session::get('Cart66InventoryWarning')) { echo Cart66Session::get('Cart66InventoryWarning'); Cart66Session::drop('Cart66InventoryWarning'); } // Build checkout form action URL $checkoutPage = get_page_by_path('store/checkout'); $ssl = Cart66Setting::getValue('auth_force_ssl'); $url = get_permalink($checkoutPage->ID); if (Cart66Common::isHttps()) { $url = str_replace('http:', 'https:', $url); } // Make it easier to get to payment, billing, and shipping data $p = $gateway->getPayment(); $b = $gateway->getBilling(); $s = $gateway->getShipping(); // Set initial country codes for billing and shipping addresses $billingCountryCode = isset($b['country']) && !empty($b['country']) ? $b['country'] : Cart66Common::getHomeCountryCode(); $shippingCountryCode = isset($s['country']) && !empty($s['country']) ? $s['country'] : Cart66Common::getHomeCountryCode();
<?php if (Cart66Session::get('zendesk_logout_error')) { ?> <div class="alert-message"> <?php _e('Zendesk logged you out with the following error', 'cart66'); ?> :<br> <?php echo Cart66Session::get('zendesk_logout_error'); ?> </div> <?php Cart66Session::drop('zendesk_logout_error'); } if (Cart66Common::isLoggedIn()) { ?> <p>Hi <?php echo $data['account']->firstName; ?> . <?php _e('You are currently logged in.', 'cart66'); ?> <a href="<?php echo Cart66Common::appendQueryString('cart66-task=logout'); ?> "><?php _e('Log out', 'cart66'); ?>
?> <a href="<?php echo Cart66Session::get('Cart66LastPage'); ?> " title="Continue Shopping" class="Cart66CartContinueShopping"><img alt="Continue Shopping" class="continueShoppingImg" src="<?php echo $continueShoppingImg; ?> " /></a> <?php } else { ?> <a href="<?php echo Cart66Session::get('Cart66LastPage'); ?> " class="Cart66ButtonSecondary" title="Continue Shopping"><?php _e('Continue Shopping', 'cart66'); ?> </a> <?php } ?> </div> <?php if ($promotion) { Cart66Session::get('Cart66Cart')->clearPromotion(); } Cart66Session::drop("terms_acceptance"); } ?>
/** * 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 } }
public function checkShippingMethodOnCheckout() { if ($_SERVER['REQUEST_METHOD'] == 'GET') { global $post; $checkoutPage = get_page_by_path('store/checkout'); if (!Cart66Setting::getValue('use_live_rates')) { Cart66Session::drop('Cart66LiveRates'); } if (is_object($checkoutPage) && isset($post->ID) && $post->ID == $checkoutPage->ID) { if (Cart66Session::get('Cart66LiveRates') && get_class(Cart66Session::get('Cart66LiveRates')) == 'Cart66LiveRates') { if (!Cart66Session::get('Cart66LiveRates')->hasValidShippingService()) { Cart66Session::set('Cart66ShippingWarning', true); $viewCartPage = get_page_by_path('store/cart'); $viewCartLink = get_permalink($viewCartPage->ID); wp_redirect($viewCartLink); exit; } } else { if (Cart66Setting::getValue('require_shipping_validation')) { if (Cart66Session::get('Cart66Cart')->requireShipping()) { $shippingMethods = Cart66Session::get('Cart66Cart')->getShippingMethods(); $selectedShippingMethod = Cart66Session::get('Cart66Cart')->getShippingMethodId(); if ($selectedShippingMethod == 'select') { Cart66Session::set('Cart66ShippingWarning', true); $viewCartPage = get_page_by_path('store/cart'); $viewCartLink = get_permalink($viewCartPage->ID); wp_redirect($viewCartLink); exit; } else { $method = new Cart66ShippingMethod(Cart66Session::get('Cart66Cart')->getShippingMethodId()); if (is_array($accepted_countries = unserialize($method->countries))) { $selectedCountry = Cart66Session::get('Cart66ShippingCountryCode'); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] accepted countries: " . print_r($accepted_countries, true)); if (!array_key_exists($selectedCountry, $accepted_countries)) { Cart66Session::set('Cart66ShippingWarning', true); $viewCartPage = get_page_by_path('store/cart'); $viewCartLink = get_permalink($viewCartPage->ID); wp_redirect($viewCartLink); exit; } } } } } } } } }
protected function _setShippingMethodFromPost() { // Not using live rates if (isset($_POST['shipping_method_id'])) { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Not using live shipping rates"); $shippingMethodId = $_POST['shipping_method_id']; $this->setShippingMethod($shippingMethodId); if (isset($_POST['shipping_country_code'])) { Cart66Session::set('Cart66ShippingCountryCode', $_POST['shipping_country_code']); } else { Cart66Session::drop('Cart66ShippingCountryCode'); } } elseif (isset($_POST['live_rates'])) { if (Cart66Session::get('Cart66LiveRates')) { Cart66Session::get('Cart66LiveRates')->setSelected($_POST['live_rates']); // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] This LIVE RATE is now set: " . Cart66Session::get('Cart66LiveRates')->getSelected()->getService()); // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Using live shipping rates to set shipping method from post: " . $_POST['live_rates']); } } }
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; } }