本文整理汇总了PHP中Cart66Common::isLoggedIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart66Common::isLoggedIn方法的具体用法?PHP Cart66Common::isLoggedIn怎么用?PHP Cart66Common::isLoggedIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart66Common
的用法示例。
在下文中一共展示了Cart66Common::isLoggedIn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verifyPageAccessRights
/**
* 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;
}
}
}
示例2: accountExpiration
public function accountExpiration($attrs, $content = null)
{
$output = false;
if (Cart66Common::isLoggedIn()) {
$data = array();
$account = new Cart66Account(Cart66Session::get('Cart66AccountId'));
$subscription = $account->getCurrentAccountSubscription($account->id);
$expirationDate = $subscription->active_until;
$format = get_option('date_format');
if (isset($attrs['format'])) {
$format = $attrs['format'];
}
$output = date($format, strtotime($expirationDate));
// expired?
if (strtotime($expirationDate) <= strtotime("now")) {
if (isset($attrs['expired'])) {
$output = $attrs['expired'];
}
if (!empty($content)) {
$output = $content;
}
}
//lifetime?
if ($subscription->lifetime == 1) {
$output = "Lifetime";
if (isset($attrs['lifetime'])) {
$output = $attrs['lifetime'];
}
}
}
return do_shortcode($output);
}
示例3: __
if ($logInLink !== false) {
echo '<h2>Your Account Is Ready</h2>';
if (Cart66Common::isLoggedIn() && $memberHomePageLink !== false) {
echo "<p><a href=\"{$memberHomePageLink}\">" . __("Members Home", "cart66") . "</a>.</p>";
} else {
echo "<p><a href=\"{$logInLink}\">" . __("Log into your account", "cart66") . "</a>.</p>";
}
}
}
?>
<?php
if ($order->hasAccount() == -1) {
?>
<?php
if (!Cart66Common::isLoggedIn()) {
?>
<h2>Please Create Your Account</h2>
<?php
if (isset($data['errors'])) {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Account creation errors: " . print_r($data, true));
echo Cart66Common::showErrors($data['errors'], 'Your account could not be created.');
echo Cart66Common::getJqErrorScript($data['jqErrors']);
}
?>
<?php
$account = $data['account'];
if (!is_object($account)) {
$account = new Cart66Account();
示例4: array
/**
* This file is referenced from Cart66ShortcodeManager
*/
$supportedGateways = array('Cart66AuthorizeNet', 'Cart66PayPalPro', 'Cart66ManualGateway', 'Cart66Eway', 'Cart66MerchantWarrior', 'Cart66PayLeap', 'Cart66Mijireh', 'Cart66Stripe', 'Cart662Checkout');
$errors = array();
$createAccount = false;
$gateway = $data['gateway'];
// Object instance inherited from Cart66GatewayAbstract
// Determine which gateway is in use
$gatewayName = get_class($data['gateway']);
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$cart = Cart66Session::get('Cart66Cart');
$account = false;
if ($cart->hasMembershipProducts() || $cart->hasSpreedlySubscriptions()) {
// Set up a new Cart66Account and start by pre-populating the data or load the logged in account
if ($accountId = Cart66Common::isLoggedIn()) {
$account = new Cart66Account($accountId);
} else {
$account = new Cart66Account();
if (isset($_POST['account'])) {
$acctData = Cart66Common::postVal('account');
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] New Account Data: " . print_r($acctData, true));
$account->firstName = $acctData['first_name'];
$account->lastName = $acctData['last_name'];
$account->email = $acctData['email'];
$account->username = $acctData['username'];
$account->password = md5($acctData['password']);
$errors = $account->validate();
$jqErrors = $account->getJqErrors();
if ($acctData['password'] != $acctData['password2']) {
$errors[] = __("Passwords do not match", "cart66");
示例5: initCheckout
public function initCheckout($amount)
{
$cart = Cart66Session::get('Cart66Cart');
$tax = $this->getTaxAmount();
$order = array('return_url' => Cart66Common::appendWurlQueryString('task=mijireh_notification'), 'tax' => $tax, 'shipping' => $cart->getShippingCost(), 'discount' => $cart->getDiscountAmount(), 'subtotal' => $cart->getSubTotal(), 'total' => number_format($cart->getGrandTotal() + $tax, 2, '.', ''), 'items' => array());
// Prepare the shipping address if it is available
if (strlen($this->_shipping['address']) > 3) {
$order['shipping_address'] = array('first_name' => $this->_shipping['firstName'], 'last_name' => $this->_shipping['lastName'], 'street' => $this->_shipping['address'], 'apt_suite' => $this->_shipping['address2'], 'city' => $this->_shipping['city'], 'state_province' => $this->_shipping['state'], 'zip_code' => $this->_shipping['zip'], 'country' => $this->_shipping['country'], 'phone' => $this->_payment['phone']);
}
// Add shipping method and promotion code as meta_data
$order['meta_data'] = array('shipping_method' => Cart66Session::get('Cart66Cart')->getShippingMethodName(), 'coupon' => Cart66Common::getPromoMessage(), 'custom-field' => $this->_payment['custom-field']);
// Add logged in users id to the meta_data for membership product upgrades/extensions
$account_id = Cart66Common::isLoggedIn();
if ($account_id) {
$order['meta_data']['account_id'] = $account_id;
}
// Add coupon code as meta_data
foreach ($cart->getItems() as $key => $item) {
$sku = $item->getItemNumber();
$order_item_data = array('sku' => $sku, 'name' => $item->getFullDisplayName(), 'price' => $item->getProductPrice(), 'quantity' => $item->getQuantity());
if ($custom_desc = $item->getCustomFieldDesc()) {
$order_item_data['name'] .= "\n" . $custom_desc;
}
if ($custom_info = $item->getCustomFieldInfo()) {
$order_item_data['name'] .= "\n" . $custom_info;
}
$order['items'][$key] = $order_item_data;
$option_info = trim($item->getOptionInfo());
if (!empty($option_info)) {
$order['meta_data']['options_' . $sku] = $option_info;
}
if ($item->hasAttachedForms()) {
$form_ids = $item->getFormEntryIds();
if (is_array($form_ids) && count($form_ids)) {
$form_ids = implode(',', $form_ids);
$order['meta_data'][$key]['gforms_' . $sku] = $form_ids;
}
}
}
// DBG
/*
echo "<pre>";
print_r($order);
echo "</pre>";
die();
*/
try {
//Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Sending Order To Mijireh" . print_r($order, true));
$access_key = Cart66Setting::getValue('mijireh_access_key');
$rest = new PestJSON(MIJIREH_CHECKOUT);
$rest->setupAuth($access_key, '');
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Sending Order To Mijireh: " . print_r($order, true));
$result = $rest->post('/api/1/orders', $order);
wp_redirect($result['checkout_url']);
//wp_redirect(MIJIREH_CHECKOUT . '/checkout/' . $result['order_number']);
exit;
} catch (Pest_Unauthorized $e) {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] REST Request Failed because it was unauthorized: " . $e->getMessage());
$this->response['error_message'] = __("Your Mijireh Access key is invalid, please check your access settings and try again", "cart66");
$this->response['error_code'] = 1;
if (strlen($this->_shipping['address']) < 3) {
$gatewayResponse = $this->getTransactionResponseDescription();
$exception = Cart66Exception::exceptionMessages(66500, __('Your order could not be processed for the following reasons:', 'cart66'), array('error_code' => 'Error: ' . $gatewayResponse['errorcode'], strtolower($gatewayResponse['errormessage'])));
echo Cart66Common::getView('views/error-messages.php', $exception);
}
} catch (Exception $e) {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] REST Request Failed: " . $e->getMessage());
}
}
示例6: hidePrivatePages
/**
* Hide private pages and pages that require a subscription feature level the subscriber does not have
*/
public function hidePrivatePages($excludes)
{
global $wpdb;
$hidePrivate = true;
$mySubItemNums = array();
$activeAccount = false;
$featureLevel = false;
if (Cart66Common::isLoggedIn()) {
$hidePrivate = false;
$account = new Cart66Account(Cart66Session::get('Cart66AccountId'));
if ($account->isActive()) {
$activeAccount = true;
$featureLevel = $account->getFeatureLevel();
}
// Optionally add the logout link to the end of the navigation
if (Cart66Setting::getValue('auto_logout_link')) {
add_filter('wp_list_pages', array($this, 'appendLogoutLink'));
}
// Hide guest only pages
$guestOnlyPageIds = Cart66AccessManager::getGuestOnlyPageIds();
$excludes = array_merge($excludes, $guestOnlyPageIds);
}
// Hide pages requiring a feature level that the subscriber does not have
$hiddenPages = Cart66AccessManager::hideSubscriptionPages($featureLevel, $activeAccount);
if (count($hiddenPages)) {
$excludes = array_merge($excludes, $hiddenPages);
}
if ($hidePrivate) {
// Build list of private page ids
$privatePageIds = Cart66AccessManager::getPrivatePageIds();
$excludes = array_merge($excludes, $privatePageIds);
}
// Merge private page ids with other excluded pages
if (is_array(get_option('exclude_pages'))) {
$excludes = array_merge(get_option('exclude_pages'), $excludes);
}
sort($excludes);
return $excludes;
}
示例7: storeOrder
public function storeOrder($orderInfo)
{
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] orderinfo: " . print_r($orderInfo, true));
$order = new Cart66Order();
$pre_string = isset($orderInfo['status']) && $orderInfo['status'] == 'checkout_pending' ? 'CP-' : 'MT-';
$orderInfo['trans_id'] = empty($orderInfo['trans_id']) ? $pre_string . Cart66Common::getRandString() : $orderInfo['trans_id'];
$orderInfo['ip'] = $_SERVER['REMOTE_ADDR'];
// Is the user logged in, if so, let's store their account ID in the order
if (Cart66Common::isLoggedIn()) {
$account = new Cart66Account();
$orderInfo['account_id'] = Cart66Session::get('Cart66AccountId');
}
if (Cart66Session::get('Cart66Promotion')) {
$orderInfo['discount_amount'] = Cart66Session::get('Cart66Promotion')->getDiscountAmount(Cart66Session::get('Cart66Cart'));
} else {
$orderInfo['discount_amount'] = 0;
}
$order->setInfo($orderInfo);
$order->setItems($this->getItems());
$orderId = $order->save();
//update the number of redemptions for the promotion code.
if (Cart66Session::get('Cart66Promotion')) {
Cart66Session::get('Cart66Promotion')->updateRedemptions();
}
$orderInfo['id'] = $orderId;
do_action('cart66_after_order_saved', $orderInfo);
return $orderId;
}
示例8: getProRateInfo
/**
* 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;
}
示例9: getDiscountAmount
public function getDiscountAmount($cartObject = null, $taxed_products = false)
{
$p = new Cart66Product();
//Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Running getDiscountAmount()");
$discount = 0;
if (!$cartObject) {
$cartObject = Cart66Session::get('Cart66Cart');
}
// First, check to see if a membership group is excluded from using this coupon
if ($this->membership_eligibility) {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] This coupon requires a membership to use:" . $this->membership_eligibility);
if (Cart66Common::isLoggedIn()) {
if ($this->membership_eligibility == "guest") {
// The user is logged in as a non-guest and this is a guest-only coupon. Return 0.00
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The user is logged in as a non-guest and this is a guest-only coupon.");
return number_format($discount, 2, '.', '');
}
$account = new Cart66Account();
if ($account->load(Cart66Session::get('Cart66AccountId'))) {
$userFeatureLevel = $account->getFeatureLevel();
$allowedLevels = Cart66Common::trimmedExplode(',', $this->membership_eligibility);
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The user is logged in as " . $userFeatureLevel);
if (!in_array($userFeatureLevel, $allowedLevels)) {
// The user is logged in, but cannot use this coupon. Return 0.00
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The user is logged in as " . $userFeatureLevel . " and is not eligible to use this coupon.");
return number_format($discount, 2, '.', '');
}
}
} else {
// The user is not logged in...and this coupon requires a login to work, no discount
if ($this->membership_eligibility && $this->membership_eligibility != "guest") {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The user is not logged in, cant use this coupon as guest.");
return number_format($discount, 2, '.', '');
}
}
}
if ($this->apply_to == "products" && !empty($cartObject)) {
// coupon applies to products
$products = explode(',', $this->products);
$cartItems = $cartObject->getItems();
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The number of items in the cart: " . count($cartItems));
$usedThisOrder = 0;
if (empty($this->products)) {
// all products
// apply coupon to every item in the cart
$counter = 0;
foreach ($cartItems as $item) {
$p->load($item->getProductId());
if (!$taxed_products || $taxed_products && $p->taxable == 1) {
$basePrice = $item->getBaseProductPrice();
$stayPositivePrice = $this->stayPositive($basePrice, $this->getAmount($basePrice));
$quantity = $item->getQuantity();
for ($i = 1; $i <= $quantity; $i++) {
if (empty($this->max_uses_per_order)) {
$discount += $stayPositivePrice;
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Max uses per order is empty. Discount: {$discount}");
} elseif ($counter < $this->max_uses_per_order) {
$discount += $stayPositivePrice;
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Max uses per order is NOT empty. Discount: {$discount} :: Stay Positive: {$stayPositivePrice}");
}
$counter++;
}
}
}
} else {
// coupon applies to specific products
foreach ($cartItems as $item) {
$p->load($item->getProductId());
if (!$taxed_products || $taxed_products && $p->taxable == 1) {
if ($this->exclude_from_products == 0) {
if (in_array($item->getProductId(), $products)) {
// add up discount
$itemQuantity = $item->getQuantity();
if ($this->max_uses_per_order > 0) {
$usesRemaining = $this->max_uses_per_order - $usedThisOrder;
$allowedQuantity = $usesRemaining <= $itemQuantity ? $usesRemaining : $itemQuantity;
} else {
$allowedQuantity = $itemQuantity;
}
$productDiscount = $this->getAmount($item->getBaseProductPrice());
$discount += $allowedQuantity * $this->stayPositive($item->getBaseProductPrice(), $productDiscount);
}
} elseif ($this->exclude_from_products == 1) {
if (!in_array($item->getProductId(), $products)) {
// add up discount
$itemQuantity = $item->getQuantity();
if ($this->max_uses_per_order > 0) {
$usesRemaining = $this->max_uses_per_order - $usedThisOrder;
$allowedQuantity = $usesRemaining <= $itemQuantity ? $usesRemaining : $itemQuantity;
} else {
$allowedQuantity = $itemQuantity;
}
$productDiscount = $this->getAmount($item->getBaseProductPrice());
$discount += $allowedQuantity * $this->stayPositive($item->getBaseProductPrice(), $productDiscount);
}
}
}
}
}
}
//.........这里部分代码省略.........