当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Subscriptions_Manager::user_has_subscription方法代码示例

本文整理汇总了PHP中WC_Subscriptions_Manager::user_has_subscription方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Manager::user_has_subscription方法的具体用法?PHP WC_Subscriptions_Manager::user_has_subscription怎么用?PHP WC_Subscriptions_Manager::user_has_subscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Subscriptions_Manager的用法示例。


在下文中一共展示了WC_Subscriptions_Manager::user_has_subscription方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: is_purchasable

 /**
  * Checks if the store manager has requested the current product be limited to one purchase
  * per customer, and if so, checks whether the customer already has an active subscription to
  * the product.
  *
  * @access public
  * @return bool
  */
 function is_purchasable()
 {
     $purchasable = parent::is_purchasable();
     if (true === $purchasable && 'yes' == $this->limit_subscriptions) {
         if (WC_Subscriptions_Manager::user_has_subscription(0, $this->id, 'active')) {
             $purchasable = false;
         }
     }
     return apply_filters('woocommerce_subscription_is_purchasable', $purchasable, $this);
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:18,代码来源:class-wc-product-subscription.php

示例2: is_purchasable

 /**
  * If a product is being marked as not purchasable because it is limited and the customer has a subscription,
  * but the current request is to switch the subscription, then mark it as purchasable.
  *
  * @since 1.4.4
  * @return bool
  */
 public static function is_purchasable($is_purchasable, $product)
 {
     global $woocommerce;
     if (false === $is_purchasable && WC_Subscriptions_Product::is_subscription($product->id) && 'yes' === $product->limit_subscriptions && WC_Subscriptions_Manager::user_has_subscription(0, $product->id, 'active')) {
         // Adding to cart from the product page
         if (isset($_GET['switch-subscription'])) {
             $is_purchasable = true;
             // Validating when restring cart from session
         } elseif (self::cart_contains_subscription_switch()) {
             $is_purchasable = true;
             // Restoring cart from session, so need to check the cart in the session (self::cart_contains_subscription_switch() only checks the cart)
         } elseif (isset($woocommerce->session->cart)) {
             foreach ($woocommerce->session->cart as $cart_item_key => $cart_item) {
                 if (isset($cart_item['subscription_switch'])) {
                     $is_purchasable = true;
                     break;
                 }
             }
         }
     }
     return $is_purchasable;
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:29,代码来源:class-wc-subscriptions-switcher.php

示例3: is_purchasable

 /**
  * Checks if the store manager has requested the current product be limited to one purchase
  * per customer, and if so, checks whether the customer already has an active subscription to
  * the product.
  *
  * @access public
  * @return bool
  */
 function is_purchasable()
 {
     $purchasable = parent::is_purchasable();
     if (true === $purchasable && 'no' != $this->limit_subscriptions && is_user_logged_in() && ('active' == $this->limit_subscriptions && WC_Subscriptions_Manager::user_has_subscription(0, $this->id, 'on-hold') || WC_Subscriptions_Manager::user_has_subscription(0, $this->id, $this->limit_subscriptions)) && false === strpos($_SERVER['REQUEST_URI'], 'order-received')) {
         // we can't use is_order_received_page() becuase get_cart_from_session() is called before the query vars are setup
         $purchasable = false;
     }
     return apply_filters('woocommerce_subscription_is_purchasable', $purchasable, $this);
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:17,代码来源:class-wc-product-variable-subscription.php

示例4: maybe_update_subscription_addresses

 /**
  * When a subscriber's billing or shipping address is successfully updated, check if the subscriber
  * has also requested to update the addresses on existing subscriptions and if so, go ahead and update
  * the addresses on the initial order for each subscription.
  *
  * @param int $user_id The ID of a user who own's the subscription (and address)
  * @since 1.3
  */
 public static function maybe_update_subscription_addresses($user_id)
 {
     global $woocommerce, $wp;
     if (!WC_Subscriptions_Manager::user_has_subscription($user_id) || !isset($_GET['address']) && !isset($wp->query_vars['edit-address'])) {
         return;
     }
     if (isset($wp->query_vars['edit-address'])) {
         $load_address = isset($wp->query_vars['edit-address']) ? sanitize_key($wp->query_vars['edit-address']) : 'billing';
     } else {
         $load_address = isset($_GET['address']) ? esc_attr($_GET['address']) : '';
     }
     $load_address = $load_address == 'billing' || $load_address == 'shipping' ? $load_address : '';
     $address_fields = $woocommerce->countries->get_address_fields(esc_attr($_POST[$load_address . '_country']), $load_address . '_');
     if (isset($_POST['update_all_subscriptions_addresses'])) {
         $users_subscriptions = WC_Subscriptions_Manager::get_users_subscriptions($user_id);
         foreach ($users_subscriptions as $subscription) {
             self::maybe_update_order_address($subscription, $address_fields);
         }
     } elseif (isset($_POST['update_subscription_address'])) {
         $subscription = WC_Subscriptions_Manager::get_subscription($_POST['update_subscription_address']);
         // Update the address only if the user actually owns the subscription
         if (!empty($subscription)) {
             self::maybe_update_order_address($subscription, $address_fields);
         }
     }
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:34,代码来源:class-wc-subscriptions-addresses.php

示例5: do_action

	<link itemprop="availability" href="http://schema.org/OutOfStock">
<?php 
} else {
    ?>

	<link itemprop="availability" href="http://schema.org/InStock">

	<?php 
    do_action('woocommerce_before_add_to_cart_form');
    ?>

	<?php 
    if (!$product->is_purchasable() && 0 != $user_id && 'no' != $product->limit_subscriptions && ('active' == $product->limit_subscriptions && WC_Subscriptions_Manager::user_has_subscription(0, $product->id, 'on-hold') || ($user_has_subscription = WC_Subscriptions_Manager::user_has_subscription($user_id, $product->id, $product->limit_subscriptions)))) {
        ?>
		<?php 
        if ('any' == $product->limit_subscriptions && $user_has_subscription && !WC_Subscriptions_Manager::user_has_subscription($user_id, $product->id, 'active') && !WC_Subscriptions_Manager::user_has_subscription($user_id, $product->id, 'on-hold')) {
            // customer has an inactive subscription, maybe offer the renewal button
            ?>
			<?php 
            $renewal_link = WC_Subscriptions_Renewal_Order::get_users_renewal_link_for_product($product->id);
            ?>
			<?php 
            if (!empty($renewal_link)) {
                ?>
				<a href="<?php 
                echo $renewal_link;
                ?>
" class="button product-renewal-link"><?php 
                _e('Renew', 'woocommerce-subscriptions');
                ?>
</a>
开发者ID:developmentDM2,项目名称:CZND,代码行数:31,代码来源:subscription.php

示例6: is_purchasable

 /**
  * If a product is being marked as not purchasable because it is limited and the customer has a subscription,
  * but the current request is to switch the subscription, then mark it as purchasable.
  *
  * @since 1.4.4
  * @return bool
  */
 public static function is_purchasable($is_purchasable, $product)
 {
     global $woocommerce;
     $allow_switching = 'no' !== get_option(WC_Subscriptions_Admin::$option_prefix . '_allow_switching', 'no');
     if (false === $is_purchasable && $allow_switching && WC_Subscriptions_Product::is_subscription($product->id) && 'no' != $product->limit_subscriptions && is_user_logged_in() && WC_Subscriptions_Manager::user_has_subscription(0, $product->id, $product->limit_subscriptions)) {
         // Adding to cart from the product page
         if (isset($_GET['switch-subscription'])) {
             $is_purchasable = true;
             // Validating when restring cart from session
         } elseif (self::cart_contains_subscription_switch()) {
             $is_purchasable = true;
             // Restoring cart from session, so need to check the cart in the session (self::cart_contains_subscription_switch() only checks the cart)
         } elseif (isset($woocommerce->session->cart)) {
             foreach ($woocommerce->session->cart as $cart_item_key => $cart_item) {
                 if ($product->id == $cart_item['product_id'] && isset($cart_item['subscription_switch'])) {
                     $is_purchasable = true;
                     break;
                 }
             }
         }
     }
     return $is_purchasable;
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:30,代码来源:class-wc-subscriptions-switcher.php

示例7: user_column_values

 /**
  * Hooked to the users table to display a check mark if a given user has an active subscription.
  *
  * @param string $value The string to output in the column specified with $column_name
  * @param string $column_name The string key for the current column in an admin table
  * @param int $user_id The ID of the user to which this row relates
  * @return string $value A check mark if the column is the active_subscriber column and the user has an active subscription.
  * @since 1.0
  */
 public static function user_column_values($value, $column_name, $user_id)
 {
     global $woocommerce;
     if ($column_name == 'woocommerce_active_subscriber') {
         if (WC_Subscriptions_Manager::user_has_subscription($user_id, '', 'active')) {
             if (WC_Subscriptions::is_woocommerce_pre_2_1()) {
                 $value = '<img src="' . $woocommerce->plugin_url() . '/assets/images/success.png" alt="yes" width="16px" />';
             } else {
                 $value = '<div class="active-subscriber"></div>';
             }
         } else {
             if (WC_Subscriptions::is_woocommerce_pre_2_1()) {
                 $value = '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" alt="no" width="16px" />';
             } else {
                 $value = '<div class="inactive-subscriber">-</div>';
             }
         }
     }
     return $value;
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:29,代码来源:class-wc-subscriptions-admin.php

示例8: column_wc_subscriber

 function column_wc_subscriber($item)
 {
     if ($item['user_id'] && !empty($item['user_id'])) {
         if (WC_Subscriptions_Manager::user_has_subscription($item['user_id'], '', 'active')) {
             return "<span class='enrolled-yes tips' data-tip='Active Subscriber'></span>";
         } else {
             return "<span>-</span>";
         }
     }
     return "<span>-</span>";
 }
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:11,代码来源:class-wc-crm-table-customers.php

示例9: maybe_update_subscription_order_addresses

 public function maybe_update_subscription_order_addresses($user_id, $load_address)
 {
     global $woocommerce, $wp;
     if (!WC_Subscriptions_Manager::user_has_subscription($user_id)) {
         return;
     }
     if ($load_address != 'shipping') {
         return;
     }
     $subscription_ids = array();
     if (isset($_POST['update_all_subscriptions_addresses'])) {
         $users_subscriptions = WC_Subscriptions_Manager::get_users_subscriptions($user_id);
         foreach ($users_subscriptions as $subscription) {
             array_push($subscription_ids, $subscription['order_id']);
         }
     } elseif (isset($_POST['update_subscription_address'])) {
         $subscription = WC_Subscriptions_Manager::get_subscription($_POST['update_subscription_address']);
         // Update the address only if the user actually owns the subscription
         if (!empty($subscription)) {
             array_push($subscription_ids, $subscription['order_id']);
         }
     }
     if (count($subscription_ids) > 0) {
         $base_order = $order = wc_get_order($subscription_ids[0]);
         $args = array('numberposts' => -1, 'post_type' => 'shop_order', 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => 'shop_order_status', 'field' => 'slug', 'terms' => array('processing'))), 'meta_query' => array(array('key' => '_customer_user', 'value' => $user_id), array('key' => '_original_order', 'value' => $subscription_ids)));
         $posts = get_posts($args);
         $address = array('first_name' => $base_order->shipping_first_name, 'last_name' => $base_order->shipping_last_name, 'address_1' => $base_order->shipping_address_1, 'address_2' => $base_order->shipping_address_2, 'city' => $base_order->shipping_city, 'state' => $base_order->shipping_state, 'postcode' => $base_order->shipping_postcode, 'country' => $base_order->shipping_country);
         foreach ($posts as $post) {
             $order = wc_get_order($post->ID);
             $order->set_address($address, 'shipping');
         }
     }
 }
开发者ID:whatthefork,项目名称:woocommerce-fedex-shipping-labels,代码行数:33,代码来源:woocommerce-fedex-shipping-labels.php

示例10: is_purchasable

 /**
  * If a product is being marked as not purchasable because it is limited and the customer has a subscription,
  * but the current request is to switch the subscription, then mark it as purchasable.
  *
  * @since 1.5
  * @return bool
  */
 public static function is_purchasable($is_purchasable, $product)
 {
     global $woocommerce;
     if (false === $is_purchasable && WC_Subscriptions_Product::is_subscription($product->id) && 'no' != $product->limit_subscriptions && is_user_logged_in() && ('active' == $product->limit_subscriptions && WC_Subscriptions_Manager::user_has_subscription(0, $product->id, 'on-hold') || WC_Subscriptions_Manager::user_has_subscription(0, $product->id, $product->limit_subscriptions))) {
         // Adding to cart from the product page
         if (isset($_GET['renew_subscription']) || isset($_GET['manual_subscription_renewal'])) {
             $is_purchasable = true;
             // Validating when restoring cart from session
         } elseif ($cart_item = WC_Subscriptions_Cart::cart_contains_subscription_renewal('parent')) {
             $is_purchasable = true;
             // Restoring cart from session, so need to check the cart in the session (WC_Subscriptions_Cart::cart_contains_subscription_renewal() only checks the cart)
         } elseif (isset($woocommerce->session->cart)) {
             foreach ($woocommerce->session->cart as $cart_item_key => $cart_item) {
                 if ($product->id == $cart_item['product_id'] && isset($cart_item['subscription_renewal'])) {
                     $is_purchasable = true;
                     break;
                 }
             }
         }
     }
     return $is_purchasable;
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:29,代码来源:class-wc-subscriptions-renewal-order.php


注:本文中的WC_Subscriptions_Manager::user_has_subscription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。