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


PHP WC_Subscriptions_Product::is_subscription方法代码示例

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


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

示例1: apply_subscription_discount_before_tax

 /**
  * Apply sign up fee or recurring fee discount before tax is calculated
  *
  *
  * @since 1.2
  */
 public static function apply_subscription_discount_before_tax($original_price, $product, $cart)
 {
     global $woocommerce;
     if (!WC_Subscriptions_Product::is_subscription($product['product_id'])) {
         return $original_price;
     }
     $price = $original_price;
     if (!empty($cart->applied_coupons)) {
         foreach ($cart->applied_coupons as $code) {
             $coupon = new WC_Coupon($code);
             if ($coupon->apply_before_tax() && $coupon->is_valid()) {
                 // Sign up fee discount
                 if ('sign_up_fee' == WC_Subscriptions_Cart::get_recalculation_type() && 'sign_up_fee' == $coupon->type || 'base_recurring_fee' == WC_Subscriptions_Cart::get_recalculation_type() && 'recurring_fee' == $coupon->type || 0 == WC_Subscriptions_Cart::get_cart_subscription_sign_up_fee() && 'recurring_fee' == $coupon->type) {
                     if ($original_price < $coupon->amount) {
                         $discount_amount = $original_price;
                     } else {
                         $discount_amount = $coupon->amount;
                     }
                     $price = $original_price - $coupon->amount;
                     if ($price < 0) {
                         $price = 0;
                     }
                     // add to discount totals
                     $woocommerce->cart->discount_cart = $woocommerce->cart->discount_cart + $discount_amount * $product['quantity'];
                 }
             }
         }
     }
     return $price;
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:36,代码来源:class-wc-subscriptions-coupon.php

示例2: is_subscription

 /**
  * Tells if a product is a subscription, provided that Subs is installed.
  *
  * @param  mixed    $product_id   product or id to check
  * @return boolean                true if Subs exists and product is a Sub
  */
 public function is_subscription($product_id)
 {
     if (!class_exists('WC_Subscriptions')) {
         return false;
     }
     return WC_Subscriptions_Product::is_subscription($product_id);
 }
开发者ID:alexbaron50,项目名称:Rockk3rs-Lab-Test,代码行数:13,代码来源:class-wc-pb-compatibility.php

示例3: calculate_potential_monthly_maximum_payment_in_cart

 /**
  * Determine the maximum monthly payment required for subscriptions currently in cart.
  * This is an approximation based on 31 day months.
  *
  * @return float
  */
 protected function calculate_potential_monthly_maximum_payment_in_cart()
 {
     $potential_monthly_max = 0;
     foreach (WC()->cart->cart_contents as $cart_item) {
         $product_subscription = $cart_item['data'];
         $item_quantity = absint($cart_item['quantity']);
         if (WC_Subscriptions_Product::is_subscription($product_subscription)) {
             $subscription_price = (double) $product_subscription->subscription_price;
             $subscription_interval = (double) $product_subscription->subscription_period_interval;
             $subscription_monthly_max = $item_quantity * $subscription_price;
             if ('day' === $product_subscription->subscription_period) {
                 $subscription_monthly_max = $subscription_price * (31 / $subscription_interval);
             } else {
                 if ('week' === $product_subscription->subscription_period) {
                     $subscription_monthly_max = $subscription_price * ceil(4 / $subscription_interval);
                 }
             }
             $potential_monthly_max += $subscription_monthly_max;
         }
     }
     return $potential_monthly_max;
 }
开发者ID:lilweirdward,项目名称:blofishwordpress,代码行数:28,代码来源:class-wc-gateway-amazon-payments-advanced-subscriptions.php

示例4: add_order_item_meta

 /**
  * Add each subscription product's details to an order so that the state of the subscription persists even when a product is changed
  *
  * @since 1.2
  */
 public static function add_order_item_meta($order_item)
 {
     global $woocommerce;
     if (WC_Subscriptions_Product::is_subscription($order_item['id'])) {
         // Make sure existing meta persists
         $item_meta = new WC_Order_Item_Meta($order_item['item_meta']);
         // Add subscription details so order state persists even when a product is changed
         $item_meta->add('_subscription_period', WC_Subscriptions_Product::get_period($order_item['id']));
         $item_meta->add('_subscription_interval', WC_Subscriptions_Product::get_interval($order_item['id']));
         $item_meta->add('_subscription_length', WC_Subscriptions_Product::get_length($order_item['id']));
         $item_meta->add('_subscription_trial_length', WC_Subscriptions_Product::get_trial_length($order_item['id']));
         $item_meta->add('_subscription_trial_period', WC_Subscriptions_Product::get_trial_period($order_item['id']));
         $item_meta->add('_subscription_recurring_amount', $woocommerce->cart->base_recurring_prices[$order_item['id']]);
         // WC_Subscriptions_Product::get_price() would return a price without filters applied
         $item_meta->add('_subscription_sign_up_fee', WC_Subscriptions_Product::get_sign_up_fee($order_item['id']));
         // Calculated recurring amounts for the item
         $item_meta->add('_recurring_line_total', $woocommerce->cart->recurring_cart_contents[$order_item['id']]['recurring_line_total']);
         $item_meta->add('_recurring_line_tax', $woocommerce->cart->recurring_cart_contents[$order_item['id']]['recurring_line_tax']);
         $item_meta->add('_recurring_line_subtotal', $woocommerce->cart->recurring_cart_contents[$order_item['id']]['recurring_line_subtotal']);
         $item_meta->add('_recurring_line_subtotal_tax', $woocommerce->cart->recurring_cart_contents[$order_item['id']]['recurring_line_subtotal_tax']);
         $order_item['item_meta'] = $item_meta->meta;
     }
     return $order_item;
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:29,代码来源:class-wc-subscriptions-checkout.php

示例5: save_subscription_meta

 /**
  * Save subscription details when edit product page is submitted for a subscription product type
  * or the bulk edit product is saved.
  * 
  * The $_REQUEST global is used to account for both $_GET submission from Bulk Edit page and 
  * $_POST submission from Edit Product page.
  * 
  * @param array Array of Product types & their labels, excluding the Subscription product type.
  * @return array Array of Product types & their labels, including the Subscription product type.
  * @since 1.0
  */
 public static function save_subscription_meta($post_id)
 {
     if (!WC_Subscriptions_Product::is_subscription($post_id)) {
         return;
     }
     if (isset($_REQUEST['_subscription_price'])) {
         update_post_meta($post_id, '_subscription_price', stripslashes($_REQUEST['_subscription_price']));
         update_post_meta($post_id, '_price', stripslashes($_REQUEST['_subscription_price']));
     } else {
         // Handle bulk edit, where _subscription_price field is not available
         if (isset($_REQUEST['_regular_price']) && !empty($_REQUEST['_regular_price'])) {
             update_post_meta($post_id, '_subscription_price', stripslashes($_REQUEST['_regular_price']));
             update_post_meta($post_id, '_price', stripslashes($_REQUEST['_regular_price']));
         } elseif (isset($_REQUEST['_sale_price']) && !empty($_REQUEST['_sale_price'])) {
             update_post_meta($post_id, '_subscription_price', stripslashes($_REQUEST['_sale_price']));
             update_post_meta($post_id, '_price', stripslashes($_REQUEST['_sale_price']));
         }
     }
     $subscription_fields = array('_subscription_sign_up_fee', '_subscription_period', '_subscription_period_interval', '_subscription_length', '_subscription_trial_length');
     foreach ($subscription_fields as $field_name) {
         if (isset($_REQUEST[$field_name])) {
             update_post_meta($post_id, $field_name, stripslashes($_REQUEST[$field_name]));
         }
     }
 }
开发者ID:picassentviu,项目名称:AMMPro,代码行数:36,代码来源:class-wc-subscriptions-admin.php

示例6: is_sold_individually

 /**
  * Subscriptions are individual items so override the WC_Product is_sold_individually function
  * to reflect this.
  *
  * @since 1.0
  */
 public static function is_sold_individually($is_individual, $product)
 {
     // Sold individually if downloadable, virtual, and the option is enabled
     if (WC_Subscriptions_Product::is_subscription($product)) {
         $is_individual = true;
     }
     return $is_individual;
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:14,代码来源:woocommerce-subscriptions.php

示例7: get_cart_subscription_sign_up_fee

 /**
  * Gets the subscription sign up fee for the cart and returns it
  *
  * Currently short-circuits to return just the sign-up fee of the first subscription, because only
  * one subscription can be purchased at a time. 
  *
  * @since 1.0
  */
 public static function get_cart_subscription_sign_up_fee()
 {
     global $woocommerce;
     $sign_up_fee = 0;
     if (!self::cart_contains_subscription_renewal()) {
         foreach ($woocommerce->cart->cart_contents as $cart_item) {
             $item_id = empty($cart_item['variation_id']) ? $cart_item['product_id'] : $cart_item['variation_id'];
             if (isset($cart_item['data']->subscription_sign_up_fee)) {
                 $sign_up_fee = $cart_item['data']->subscription_sign_up_fee;
                 break;
             } elseif (WC_Subscriptions_Product::is_subscription($item_id)) {
                 $sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee($item_id);
                 break;
             }
         }
     }
     return apply_filters('woocommerce_subscriptions_cart_sign_up_fee', $sign_up_fee);
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:26,代码来源:class-wc-subscriptions-cart.php

示例8: process_product_meta_variable_subscription

 /**
  * Save a variable subscription's details when the edit product page is submitted for a variable
  * subscription product type (or the bulk edit product is saved).
  *
  * @param $post_id int ID of the parent WC_Product_Variable_Subscription
  * @return null
  * @since 1.3
  */
 public static function process_product_meta_variable_subscription($post_id)
 {
     if (!WC_Subscriptions_Product::is_subscription($post_id)) {
         return;
     }
     // Make sure WooCommerce calculates correct prices
     $_POST['variable_regular_price'] = $_POST['variable_subscription_price'];
     // Run WooCommerce core saving routine
     process_product_meta_variable($post_id);
     if (!isset($_REQUEST['_subscription_limit'])) {
         $_REQUEST['_subscription_limit'] = 'no';
     }
     update_post_meta($post_id, '_subscription_limit', stripslashes($_REQUEST['_subscription_limit']));
     if (!isset($_REQUEST['variable_post_id'])) {
         return;
     }
     $variable_post_ids = $_POST['variable_post_id'];
     $max_loop = max(array_keys($variable_post_ids));
     // Save each variations details
     for ($i = 0; $i <= $max_loop; $i++) {
         if (!isset($variable_post_ids[$i])) {
             continue;
         }
         $variation_id = absint($variable_post_ids[$i]);
         if (isset($_POST['variable_subscription_price']) && is_array($_POST['variable_subscription_price'])) {
             $subscription_price = self::clean_number(woocommerce_clean($_POST['variable_subscription_price'][$i]));
             update_post_meta($variation_id, '_subscription_price', $subscription_price);
             update_post_meta($variation_id, '_regular_price', $subscription_price);
         }
         // Make sure trial period is within allowable range
         $subscription_ranges = WC_Subscriptions_Manager::get_subscription_ranges();
         $max_trial_length = count($subscription_ranges[$_POST['variable_subscription_trial_period'][$i]]) - 1;
         $_POST['variable_subscription_trial_length'][$i] = absint($_POST['variable_subscription_trial_length'][$i]);
         if ($_POST['variable_subscription_trial_length'][$i] > $max_trial_length) {
             $_POST['variable_subscription_trial_length'][$i] = $max_trial_length;
         }
         $subscription_fields = array('_subscription_sign_up_fee', '_subscription_period', '_subscription_period_interval', '_subscription_length', '_subscription_trial_period', '_subscription_trial_length');
         foreach ($subscription_fields as $field_name) {
             if (isset($_POST['variable' . $field_name][$i])) {
                 update_post_meta($variation_id, $field_name, woocommerce_clean($_POST['variable' . $field_name][$i]));
             }
         }
     }
     // Now that all the varation's meta is saved, sync the min variation price
     $variable_subscription = get_product($post_id);
     $variable_subscription->variable_product_sync();
 }
开发者ID:bulats,项目名称:chef,代码行数:55,代码来源:class-wc-subscriptions-admin.php

示例9: 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

示例10: create_pending_subscription_for_order

 /**
  * Uses the details of an order to create a pending subscription on the customers account
  * for a subscription product, as specified with $product_id.
  *
  * @param int|WC_Order $order The order ID or WC_Order object to create the subscription from.
  * @param int $product_id The ID of the subscription product on the order, if a variation, it must be the variation's ID.
  * @param array $args An array of name => value pairs to customise the details of the subscription, including:
  * 			'start_date' A MySQL formatted date/time string on which the subscription should start, in UTC timezone
  * 			'expiry_date' A MySQL formatted date/time string on which the subscription should expire, in UTC timezone
  * @since 1.1
  */
 public static function create_pending_subscription_for_order($order, $product_id, $args = array())
 {
     _deprecated_function(__METHOD__, '2.0', 'wcs_create_subscription()');
     if (!is_object($order)) {
         $order = new WC_Order($order);
     }
     if (!WC_Subscriptions_Product::is_subscription($product_id)) {
         return;
     }
     $args = wp_parse_args($args, array('start_date' => get_gmt_from_date($order->order_date), 'expiry_date' => ''));
     $billing_period = WC_Subscriptions_Product::get_period($product_id);
     $billing_interval = WC_Subscriptions_Product::get_interval($product_id);
     // Support passing timestamps
     $args['start_date'] = is_numeric($args['start_date']) ? date('Y-m-d H:i:s', $args['start_date']) : $args['start_date'];
     $product = wc_get_product($product_id);
     // Check if there is already a subscription for this product and order
     $subscriptions = wcs_get_subscriptions(array('order_id' => $order->id, 'product_id' => $product_id));
     if (!empty($subscriptions)) {
         $subscription = array_pop($subscriptions);
         // Make sure the subscription is pending and start date is set correctly
         wp_update_post(array('ID' => $subscription->id, 'post_status' => 'wc-' . apply_filters('woocommerce_default_subscription_status', 'pending'), 'post_date' => get_date_from_gmt($args['start_date'])));
     } else {
         $subscription = wcs_create_subscription(array('start_date' => get_date_from_gmt($args['start_date']), 'order_id' => $order->id, 'customer_id' => $order->get_user_id(), 'billing_period' => $billing_period, 'billing_interval' => $billing_interval, 'customer_note' => $order->customer_note));
         if (is_wp_error($subscription)) {
             throw new Exception(__('Error: Unable to create subscription. Please try again.', 'woocommerce-subscriptions'));
         }
         $item_id = $subscription->add_product($product, 1, array('variation' => method_exists($product, 'get_variation_attributes') ? $product->get_variation_attributes() : array(), 'totals' => array('subtotal' => $product->get_price(), 'subtotal_tax' => 0, 'total' => $product->get_price(), 'tax' => 0, 'tax_data' => array('subtotal' => array(), 'total' => array()))));
         if (!$item_id) {
             throw new Exception(__('Error: Unable to add product to created subscription. Please try again.', 'woocommerce-subscriptions'));
         }
     }
     // Make sure some of the meta is copied form the order rather than the store's defaults
     update_post_meta($subscription->id, '_order_currency', $order->order_currency);
     update_post_meta($subscription->id, '_prices_include_tax', $order->prices_include_tax);
     // Adding a new subscription so set the expiry date/time from the order date
     if (!empty($args['expiry_date'])) {
         if (is_numeric($args['expiry_date'])) {
             $args['expiry_date'] = date('Y-m-d H:i:s', $args['expiry_date']);
         }
         $expiration = $args['expiry_date'];
     } else {
         $expiration = WC_Subscriptions_Product::get_expiration_date($product_id, $args['start_date']);
     }
     // Adding a new subscription so set the expiry date/time from the order date
     $trial_expiration = WC_Subscriptions_Product::get_trial_expiration_date($product_id, $args['start_date']);
     $dates_to_update = array();
     if ($trial_expiration > 0) {
         $dates_to_update['trial_end'] = $trial_expiration;
     }
     if ($expiration > 0) {
         $dates_to_update['end'] = $expiration;
     }
     if (!empty($dates_to_update)) {
         $subscription->update_dates($dates_to_update);
     }
     // Set the recurring totals on the subscription
     $subscription->set_total(0, 'tax');
     $subscription->set_total($product->get_price(), 'total');
     $subscription->add_order_note(__('Pending subscription created.', 'woocommerce-subscriptions'));
     do_action('pending_subscription_created_for_order', $order, $product_id);
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:72,代码来源:class-wc-subscriptions-manager.php

示例11: charge_shipping_up_front

 /**
  * Let other functions know shipping should not be charged on the initial order when
  * the cart contains a synchronised subscription and no other items which need shipping.
  *
  * @since 1.5.8
  * @deprecated 2.0
  */
 public static function charge_shipping_up_front($charge_shipping_up_front)
 {
     _deprecated_function(__METHOD__, '2.0');
     // the cart contains only the synchronised subscription
     if (true === $charge_shipping_up_front && self::cart_contains_synced_subscription()) {
         // the cart contains only a subscription, see if the payment date is today and if not, then it doesn't need shipping
         if (1 == count(WC()->cart->cart_contents)) {
             foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
                 if (self::is_product_synced($cart_item['data']) && !self::is_product_prorated($cart_item['data']) && !self::is_today(self::calculate_first_payment_date($cart_item['data'], 'timestamp'))) {
                     $charge_shipping_up_front = false;
                     break;
                 }
             }
             // cart contains other items, see if any require shipping
         } else {
             $other_items_need_shipping = false;
             foreach (WC()->cart->cart_contents as $cart_item_key => $cart_item) {
                 if ((!WC_Subscriptions_Product::is_subscription($cart_item['data']) || self::is_product_prorated($cart_item['data'])) && $cart_item['data']->needs_shipping()) {
                     $other_items_need_shipping = true;
                 }
             }
             if (false === $other_items_need_shipping) {
                 $charge_shipping_up_front = false;
             }
         }
     }
     return $charge_shipping_up_front;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:35,代码来源:class-wc-subscriptions-synchroniser.php

示例12: add_order_item_meta

 /**
  * Add each subscription product's details to an order so that the state of the subscription persists even when a product is changed
  *
  * @since 1.2.5
  */
 public static function add_order_item_meta($item_id, $values)
 {
     global $woocommerce;
     if (!WC_Subscriptions_Cart::cart_contains_subscription_renewal('child') && WC_Subscriptions_Product::is_subscription($values['product_id'])) {
         $cart_item = $values['data'];
         $product_id = empty($values['variation_id']) ? $values['product_id'] : $values['variation_id'];
         // Add subscription details so order state persists even when a product is changed
         $period = isset($cart_item->subscription_period) ? $cart_item->subscription_period : WC_Subscriptions_Product::get_period($product_id);
         $interval = isset($cart_item->subscription_period_interval) ? $cart_item->subscription_period_interval : WC_Subscriptions_Product::get_interval($product_id);
         $length = isset($cart_item->subscription_length) ? $cart_item->subscription_length : WC_Subscriptions_Product::get_length($product_id);
         $trial_length = isset($cart_item->subscription_trial_length) ? $cart_item->subscription_trial_length : WC_Subscriptions_Product::get_trial_length($product_id);
         $trial_period = isset($cart_item->subscription_trial_period) ? $cart_item->subscription_trial_period : WC_Subscriptions_Product::get_trial_period($product_id);
         $sign_up_fee = isset($cart_item->subscription_sign_up_fee) ? $cart_item->subscription_sign_up_fee : WC_Subscriptions_Product::get_sign_up_fee($product_id);
         woocommerce_add_order_item_meta($item_id, '_subscription_period', $period);
         woocommerce_add_order_item_meta($item_id, '_subscription_interval', $interval);
         woocommerce_add_order_item_meta($item_id, '_subscription_length', $length);
         woocommerce_add_order_item_meta($item_id, '_subscription_trial_length', $trial_length);
         woocommerce_add_order_item_meta($item_id, '_subscription_trial_period', $trial_period);
         woocommerce_add_order_item_meta($item_id, '_subscription_recurring_amount', $woocommerce->cart->base_recurring_prices[$product_id]);
         // WC_Subscriptions_Product::get_price() would return a price without filters applied
         woocommerce_add_order_item_meta($item_id, '_subscription_sign_up_fee', $sign_up_fee);
         // Calculated recurring amounts for the item
         woocommerce_add_order_item_meta($item_id, '_recurring_line_total', $woocommerce->cart->recurring_cart_contents[$values['product_id']]['recurring_line_total']);
         woocommerce_add_order_item_meta($item_id, '_recurring_line_tax', $woocommerce->cart->recurring_cart_contents[$values['product_id']]['recurring_line_tax']);
         woocommerce_add_order_item_meta($item_id, '_recurring_line_subtotal', $woocommerce->cart->recurring_cart_contents[$values['product_id']]['recurring_line_subtotal']);
         woocommerce_add_order_item_meta($item_id, '_recurring_line_subtotal_tax', $woocommerce->cart->recurring_cart_contents[$values['product_id']]['recurring_line_subtotal_tax']);
         // Add recurring line tax data (for WC 2.2+)
         $raw_tax_data = $woocommerce->cart->recurring_cart_contents[$values['product_id']]['recurring_line_tax_data'];
         $recurring_tax_data = array();
         $recurring_tax_data['total'] = array_map('wc_format_decimal', $raw_tax_data['total']);
         $recurring_tax_data['subtotal'] = array_map('wc_format_decimal', $raw_tax_data['subtotal']);
         woocommerce_add_order_item_meta($item_id, '_recurring_line_tax_data', $recurring_tax_data);
     }
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:39,代码来源:class-wc-subscriptions-checkout.php

示例13: woocommerce_product_after_variable_attributes

 /**
  * Renders group selections for variations.
  * 
  * @param int $loop
  * @param array $variation_data
  * @param WP_Post $variation
  */
 public static function woocommerce_product_after_variable_attributes($loop, $variation_data, $variation)
 {
     global $post, $wpdb;
     $output = '';
     $output .= '<tr><td><div>';
     $variation_groups = get_post_meta($variation->ID, '_groups_variation_groups', false);
     $variation_groups_remove = get_post_meta($variation->ID, '_groups_variation_groups_remove', false);
     $groups_table = _groups_get_tablename('group');
     if ($groups = $wpdb->get_results("SELECT * FROM {$groups_table} ORDER BY name")) {
         // text style
         $output .= '<style type="text/css">';
         $output .= '.groups-woocommerce .selectize-input { font-size: inherit; }';
         $output .= '</style>';
         // add to groups
         $output .= '<label>';
         $output .= __('Add to Groups', GROUPS_WS_PLUGIN_DOMAIN);
         $output .= ' ';
         $output .= sprintf('<select id="variation-groups-%d" class="groups-woocommerce" name="_groups_variation_groups[%d][]" multiple="multiple" placeholder="%s" data-placeholder="%s">', esc_attr($variation->ID), esc_attr($variation->ID), esc_attr(__('Choose groups &hellip;', GROUPS_WS_PLUGIN_DOMAIN)), esc_attr(__('Choose groups &hellip;', GROUPS_WS_PLUGIN_DOMAIN)));
         foreach ($groups as $group) {
             $selected = is_array($variation_groups) && in_array($group->group_id, $variation_groups);
             $output .= sprintf('<option value="%d" %s>%s</option>', Groups_Utility::id($group->group_id), $selected ? ' selected="selected" ' : '', wp_filter_nohtml_kses($group->name));
         }
         $output .= '</select>';
         $output .= '</label>';
         $output .= Groups_UIE::render_select('#variation-groups-' . esc_attr($variation->ID));
         $output .= '<p class="description">' . __('Add the customer to these groups when purchasing this variation.', GROUPS_WS_PLUGIN_DOMAIN) . '</p>';
         // remove from groups
         $output .= '<label>';
         $output .= __('Remove from Groups', GROUPS_WS_PLUGIN_DOMAIN);
         $output .= ' ';
         $output .= sprintf('<select id="variation-groups-remove-%d" class="groups-woocommerce" name="_groups_variation_groups_remove[%d][]" multiple="multiple" placeholder="%s" data-placeholder="%s">', esc_attr($variation->ID), esc_attr($variation->ID), esc_attr(__('Choose groups &hellip;', GROUPS_WS_PLUGIN_DOMAIN)), esc_attr(__('Choose groups &hellip;', GROUPS_WS_PLUGIN_DOMAIN)));
         foreach ($groups as $group) {
             $selected = is_array($variation_groups_remove) && in_array($group->group_id, $variation_groups_remove);
             $output .= sprintf('<option value="%d" %s>%s</option>', Groups_Utility::id($group->group_id), $selected ? ' selected="selected" ' : '', wp_filter_nohtml_kses($group->name));
         }
         $output .= '</select>';
         $output .= '</label>';
         $output .= Groups_UIE::render_select('#variation-groups-remove-' . esc_attr($variation->ID));
         $output .= '<p class="description">' . __('Remove the customer from these groups when purchasing this variation.', GROUPS_WS_PLUGIN_DOMAIN) . '</p>';
         $is_subscription = isset($post->ID) && class_exists('WC_Subscriptions_Product') && WC_Subscriptions_Product::is_subscription($post->ID);
         $output .= sprintf('<div class="groups-panel-item-simple" style="%s">', $is_subscription ? 'display:none;' : '');
         $output .= '<p>' . __('If set, the duration limitations in the <em>Groups</em> settings of the variable product apply.', GROUPS_WS_PLUGIN_DOMAIN) . '</p>';
         $output .= '</div>';
     }
     $output .= '</div></td></tr>';
     echo $output;
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:54,代码来源:class-groups-ws-product.php

示例14: get_cart_subscription_trial_period

 /**
  * Gets the subscription trial period from the cart and returns it as an array (eg. array( 'month', 'day' ) )
  *
  * Deprecated because a cart can now contain multiple subscription products, so there is no single trial period for the entire cart.
  *
  * @since 1.2
  * @deprecated 2.0
  */
 public static function get_cart_subscription_trial_period()
 {
     _deprecated_function(__METHOD__, '2.0', 'values from WC()->cart->recurring_carts');
     $trial_period = '';
     // Get the original trial period
     if (self::cart_contains_subscription()) {
         foreach (WC()->cart->cart_contents as $cart_item) {
             if (isset($cart_item['data']->subscription_trial_period)) {
                 $trial_period = $cart_item['data']->subscription_trial_period;
                 break;
             } elseif (WC_Subscriptions_Product::is_subscription($cart_item['data'])) {
                 $trial_period = WC_Subscriptions_Product::get_trial_period($cart_item['data']);
                 break;
             }
         }
     }
     return apply_filters('woocommerce_subscriptions_cart_trial_period', $trial_period);
 }
开发者ID:slavic18,项目名称:cats,代码行数:26,代码来源:class-wc-subscriptions-cart.php

示例15: wc_json_search_subscription_products

 /**
  * Search for products and return a JSON-encoded string of results
  * using $_GET['term'] as the search term
  */
 public static function wc_json_search_subscription_products()
 {
     check_ajax_referer('search-products', 'security');
     header('Content-Type: application/json; charset=utf-8');
     $term = (string) wc_clean(stripslashes($_GET['term']));
     $post_types = array('product', 'product_variation');
     if (empty($term)) {
         die;
     }
     if (is_numeric($term)) {
         $args = array('post_type' => $post_types, 'post_status' => 'publish', 'posts_per_page' => -1, 'post__in' => array(0, $term), 'fields' => 'ids');
         $args2 = array('post_type' => $post_types, 'post_status' => 'publish', 'posts_per_page' => -1, 'post_parent' => $term, 'fields' => 'ids');
         $args3 = array('post_type' => $post_types, 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_sku', 'value' => $term, 'compare' => 'LIKE')), 'fields' => 'ids');
         $posts = array_unique(array_merge(get_posts($args), get_posts($args2), get_posts($args3)));
     } else {
         $args = array('post_type' => $post_types, 'post_status' => 'publish', 'posts_per_page' => -1, 's' => $term, 'fields' => 'ids');
         $args2 = array('post_type' => $post_types, 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_sku', 'value' => $term, 'compare' => 'LIKE')), 'fields' => 'ids');
         $posts = array_unique(array_merge(get_posts($args), get_posts($args2)));
     }
     $found_products = array();
     if ($posts) {
         foreach ($posts as $post) {
             $product = get_product($post);
             if (WC_Subscriptions_Product::is_subscription($product)) {
                 $found_products[$post] = $product->get_formatted_name();
             }
         }
     }
     $found_products = apply_filters('woocommerce_json_search_found_products', $found_products);
     echo json_encode($found_products);
     die;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:36,代码来源:class-fue-ajax.php


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