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


PHP WC_Coupon::get_product_categories方法代码示例

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


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

示例1: check_get_coupon_response

 /**
  * Ensure valid coupon data response.
  * @since 2.7.0
  * @param array $response
  * @param WC_Coupon $coupon
  */
 protected function check_get_coupon_response($response, $coupon)
 {
     $this->assertEquals((int) $coupon->get_id(), $response['id']);
     $this->assertEquals($coupon->get_code(), $response['code']);
     $this->assertEquals($coupon->get_discount_type(), $response['type']);
     $this->assertEquals($coupon->get_amount(), $response['amount']);
     $this->assertEquals($coupon->get_individual_use(), $response['individual_use']);
     $this->assertEquals($coupon->get_product_ids(), $response['product_ids']);
     $this->assertEquals($coupon->get_excluded_product_ids(), $response['exclude_product_ids']);
     $this->assertEquals((int) $coupon->get_usage_limit(), $response['usage_limit']);
     $this->assertEquals((int) $coupon->get_usage_limit_per_user(), $response['usage_limit_per_user']);
     $this->assertEquals((int) $coupon->get_limit_usage_to_x_items(), $response['limit_usage_to_x_items']);
     $this->assertEquals((int) $coupon->get_usage_count(), $response['usage_count']);
     $this->assertEquals($coupon->get_expiry_date(), $response['expiry_date']);
     $this->assertEquals($coupon->get_free_shipping(), $response['enable_free_shipping']);
     $this->assertEquals($coupon->get_product_categories(), $response['product_category_ids']);
     $this->assertEquals($coupon->get_excluded_product_categories(), $response['exclude_product_category_ids']);
     $this->assertEquals($coupon->get_exclude_sale_items(), $response['exclude_sale_items']);
     $this->assertEquals(wc_format_decimal($coupon->get_minimum_amount(), 2), $response['minimum_amount']);
     $this->assertEquals(wc_format_decimal($coupon->get_maximum_amount(), 2), $response['maximum_amount']);
     $this->assertEquals($coupon->get_email_restrictions(), $response['customer_emails']);
     $this->assertEquals($coupon->get_description(), $response['description']);
     $this->assertArrayHasKey('created_at', $response);
     $this->assertArrayHasKey('updated_at', $response);
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:31,代码来源:coupons.php

示例2: test_coupon_backwards_compat_props_use_correct_getters

 /**
  * Test that properties can still be accessed directly for backwards
  * compat sake. They throw a deprecated notice.
  * @since 2.7.0
  */
 public function test_coupon_backwards_compat_props_use_correct_getters()
 {
     // Accessing properties directly will throw some wanted deprected notices
     // So we need to let PHPUnit know we are expecting them and it's fine to continue
     $legacy_keys = array('id', 'exists', 'coupon_custom_fields', 'type', 'discount_type', 'amount', 'code', 'individual_use', 'product_ids', 'exclude_product_ids', 'usage_limit', 'usage_limit_per_user', 'limit_usage_to_x_items', 'usage_count', 'expiry_date', 'product_categories', 'exclude_product_categories', 'minimum_amount', 'maximum_amount', 'customer_email');
     $this->expected_doing_it_wrong = array_merge($this->expected_doing_it_wrong, $legacy_keys);
     $coupon = WC_Helper_Coupon::create_coupon();
     $coupon->add_meta_data('test_coupon_field', 'testing', true);
     $coupon->save_meta_data();
     $coupon = new WC_Coupon($coupon->get_id());
     $this->assertEquals($coupon->get_id(), $coupon->id);
     $this->assertEquals($coupon->get_id() > 0 ? true : false, $coupon->exists);
     $coupon_cf = $coupon->get_meta('test_coupon_field');
     $this->assertEquals($coupon_cf, $coupon->coupon_custom_fields['test_coupon_field'][0]);
     $this->assertEquals($coupon->get_discount_type(), $coupon->type);
     $this->assertEquals($coupon->get_discount_type(), $coupon->discount_type);
     $this->assertEquals($coupon->get_amount(), $coupon->amount);
     $this->assertEquals($coupon->get_code(), $coupon->code);
     $this->assertEquals($coupon->get_individual_use(), 'yes' === $coupon->individual_use ? true : false);
     $this->assertEquals($coupon->get_product_ids(), $coupon->product_ids);
     $this->assertEquals($coupon->get_excluded_product_ids(), $coupon->exclude_product_ids);
     $this->assertEquals($coupon->get_usage_limit(), $coupon->usage_limit);
     $this->assertEquals($coupon->get_usage_limit_per_user(), $coupon->usage_limit_per_user);
     $this->assertEquals($coupon->get_limit_usage_to_x_items(), $coupon->limit_usage_to_x_items);
     $this->assertEquals($coupon->get_usage_count(), $coupon->usage_count);
     $this->assertEquals($coupon->get_date_expires(), $coupon->expiry_date);
     $this->assertEquals($coupon->get_product_categories(), $coupon->product_categories);
     $this->assertEquals($coupon->get_excluded_product_categories(), $coupon->exclude_product_categories);
     $this->assertEquals($coupon->get_minimum_amount(), $coupon->minimum_amount);
     $this->assertEquals($coupon->get_maximum_amount(), $coupon->maximum_amount);
     $this->assertEquals($coupon->get_email_restrictions(), $coupon->customer_email);
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:37,代码来源:data.php

示例3: get_coupon

 /**
  * Get the coupon for the given ID
  *
  * @since 2.1
  * @param int $id the coupon ID
  * @param string $fields fields to include in response
  * @return array|WP_Error
  */
 public function get_coupon($id, $fields = null)
 {
     $id = $this->validate_request($id, 'shop_coupon', 'read');
     if (is_wp_error($id)) {
         return $id;
     }
     $coupon = new WC_Coupon($id);
     if (0 === $coupon->get_id()) {
         throw new WC_API_Exception('woocommerce_api_invalid_coupon_id', __('Invalid coupon ID', 'woocommerce'), 404);
     }
     $coupon_data = array('id' => $coupon->get_id(), 'code' => $coupon->get_code(), 'type' => $coupon->get_discount_type(), 'created_at' => $this->server->format_datetime($coupon->get_date_created(), false, true), 'updated_at' => $this->server->format_datetime($coupon->get_date_modified(), false, true), 'amount' => wc_format_decimal($coupon->get_amount(), 2), 'individual_use' => $coupon->get_individual_use(), 'product_ids' => array_map('absint', (array) $coupon->get_product_ids()), 'exclude_product_ids' => array_map('absint', (array) $coupon->get_excluded_product_ids()), 'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null, 'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null, 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), 'usage_count' => (int) $coupon->get_usage_count(), 'expiry_date' => $this->server->format_datetime($coupon->get_date_expires(), false, true), 'enable_free_shipping' => $coupon->get_free_shipping(), 'product_category_ids' => array_map('absint', (array) $coupon->get_product_categories()), 'exclude_product_category_ids' => array_map('absint', (array) $coupon->get_excluded_product_categories()), 'exclude_sale_items' => $coupon->get_exclude_sale_items(), 'minimum_amount' => wc_format_decimal($coupon->get_minimum_amount(), 2), 'customer_emails' => $coupon->get_email_restrictions());
     return array('coupon' => apply_filters('woocommerce_api_coupon_response', $coupon_data, $coupon, $fields, $this->server));
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:21,代码来源:class-wc-api-coupons.php

示例4: prepare_item_for_response

 /**
  * Prepare a single coupon output for response.
  *
  * @param WP_Post $post Post object.
  * @param WP_REST_Request $request Request object.
  * @return WP_REST_Response $data
  */
 public function prepare_item_for_response($post, $request)
 {
     // Get the coupon code.
     $code = wc_get_coupon_code_by_id($post->ID);
     $coupon = new WC_Coupon($code);
     $data = array('id' => $coupon->get_id(), 'code' => $coupon->get_code(), 'date_created' => wc_rest_prepare_date_response($post->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($post->post_modified_gmt), 'discount_type' => $coupon->get_discount_type(), 'description' => $coupon->get_description(), 'amount' => wc_format_decimal($coupon->get_amount(), 2), 'expiry_date' => $coupon->get_expiry_date() ? wc_rest_prepare_date_response($coupon->get_expiry_date()) : null, 'usage_count' => (int) $coupon->get_usage_count(), 'individual_use' => $coupon->get_individual_use(), 'product_ids' => array_map('absint', (array) $coupon->get_product_ids()), 'exclude_product_ids' => array_map('absint', (array) $coupon->get_excluded_product_ids()), 'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null, 'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null, 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), 'free_shipping' => $coupon->get_free_shipping(), 'product_categories' => array_map('absint', (array) $coupon->get_product_categories()), 'excluded_product_categories' => array_map('absint', (array) $coupon->get_excluded_product_categories()), 'exclude_sale_items' => $coupon->get_exclude_sale_items(), 'minimum_amount' => wc_format_decimal($coupon->get_minimum_amount(), 2), 'maximum_amount' => wc_format_decimal($coupon->get_maximum_amount(), 2), 'email_restrictions' => $coupon->get_email_restrictions(), 'used_by' => $coupon->get_used_by());
     $context = !empty($request['context']) ? $request['context'] : 'view';
     $data = $this->add_additional_fields_to_object($data, $request);
     $data = $this->filter_response_by_context($data, $context);
     // Wrap the data in a response object.
     $response = rest_ensure_response($data);
     $response->add_links($this->prepare_links($post));
     /**
      * Filter the data for a response.
      *
      * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being
      * prepared for the response.
      *
      * @param WP_REST_Response   $response   The response object.
      * @param WP_Post            $post       Post object.
      * @param WP_REST_Request    $request    Request object.
      */
     return apply_filters("woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request);
 }
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:31,代码来源:class-wc-rest-coupons-controller.php

示例5: output


//.........这里部分代码省略.........
        _e('Exclude products', 'woocommerce');
        ?>
</label>
				<input type="hidden" class="wc-product-search" data-multiple="true" style="width: 50%;" name="exclude_product_ids" data-placeholder="<?php 
        esc_attr_e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_products_and_variations" data-selected="<?php 
        $product_ids = $coupon->get_excluded_product_ids();
        $json_ids = array();
        foreach ($product_ids as $product_id) {
            $product = wc_get_product($product_id);
            if (is_object($product)) {
                $json_ids[$product_id] = wp_kses_post($product->get_formatted_name());
            }
        }
        echo esc_attr(json_encode($json_ids));
        ?>
" value="<?php 
        echo implode(',', array_keys($json_ids));
        ?>
" /> <?php 
        echo wc_help_tip(__('Products which must not be in the cart to use this coupon or, for "Product Discounts", which products are not discounted.', 'woocommerce'));
        ?>
</p>
				<?php 
        echo '</div><div class="options_group">';
        // Categories
        ?>
				<p class="form-field"><label for="product_categories"><?php 
        _e('Product categories', 'woocommerce');
        ?>
</label>
				<select id="product_categories" name="product_categories[]" style="width: 50%;"  class="wc-enhanced-select" multiple="multiple" data-placeholder="<?php 
        esc_attr_e('Any category', 'woocommerce');
        ?>
">
					<?php 
        $category_ids = $coupon->get_product_categories();
        $categories = get_terms('product_cat', 'orderby=name&hide_empty=0');
        if ($categories) {
            foreach ($categories as $cat) {
                echo '<option value="' . esc_attr($cat->term_id) . '"' . selected(in_array($cat->term_id, $category_ids), true, false) . '>' . esc_html($cat->name) . '</option>';
            }
        }
        ?>
				</select> <?php 
        echo wc_help_tip(__('A product must be in this category for the coupon to remain valid or, for "Product Discounts", products in these categories will be discounted.', 'woocommerce'));
        ?>
</p>
				<?php 
        // Exclude Categories
        ?>
				<p class="form-field"><label for="exclude_product_categories"><?php 
        _e('Exclude categories', 'woocommerce');
        ?>
</label>
				<select id="exclude_product_categories" name="exclude_product_categories[]" style="width: 50%;"  class="wc-enhanced-select" multiple="multiple" data-placeholder="<?php 
        esc_attr_e('No categories', 'woocommerce');
        ?>
">
					<?php 
        $category_ids = $coupon->get_excluded_product_categories();
        $categories = get_terms('product_cat', 'orderby=name&hide_empty=0');
        if ($categories) {
            foreach ($categories as $cat) {
                echo '<option value="' . esc_attr($cat->term_id) . '"' . selected(in_array($cat->term_id, $category_ids), true, false) . '>' . esc_html($cat->name) . '</option>';
            }
        }
        ?>
				</select> <?php 
        echo wc_help_tip(__('Product must not be in this category for the coupon to remain valid or, for "Product Discounts", products in these categories will not be discounted.', 'woocommerce'));
        ?>
</p>
				<?php 
        echo '</div><div class="options_group">';
        // Customers
        woocommerce_wp_text_input(array('id' => 'customer_email', 'label' => __('Email restrictions', 'woocommerce'), 'placeholder' => __('No restrictions', 'woocommerce'), 'description' => __('List of allowed emails to check against the customer\'s billing email when an order is placed. Separate email addresses with commas.', 'woocommerce'), 'value' => implode(', ', (array) get_post_meta($post->ID, 'customer_email', true)), 'desc_tip' => true, 'type' => 'email', 'class' => '', 'custom_attributes' => array('multiple' => 'multiple')));
        echo '</div>';
        do_action('woocommerce_coupon_options_usage_restriction');
        ?>
</div>
			<div id="usage_limit_coupon_data" class="panel woocommerce_options_panel"><?php 
        echo '<div class="options_group">';
        // Usage limit per coupons
        woocommerce_wp_text_input(array('id' => 'usage_limit', 'label' => __('Usage limit per coupon', 'woocommerce'), 'placeholder' => esc_attr__('Unlimited usage', 'woocommerce'), 'description' => __('How many times this coupon can be used before it is void.', 'woocommerce'), 'type' => 'number', 'desc_tip' => true, 'class' => 'short', 'custom_attributes' => array('step' => 1, 'min' => 0), 'value' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : ''));
        // Usage limit per product
        woocommerce_wp_text_input(array('id' => 'limit_usage_to_x_items', 'label' => __('Limit usage to X items', 'woocommerce'), 'placeholder' => esc_attr__('Apply to all qualifying items in cart', 'woocommerce'), 'description' => __('The maximum number of individual items this coupon can apply to when using product discounts. Leave blank to apply to all qualifying items in cart.', 'woocommerce'), 'desc_tip' => true, 'class' => 'short', 'type' => 'number', 'custom_attributes' => array('step' => 1, 'min' => 0), 'value' => $coupon->get_limit_usage_to_x_items() ? $coupon->get_limit_usage_to_x_items() : ''));
        // Usage limit per users
        woocommerce_wp_text_input(array('id' => 'usage_limit_per_user', 'label' => __('Usage limit per user', 'woocommerce'), 'placeholder' => esc_attr__('Unlimited usage', 'woocommerce'), 'description' => __('How many times this coupon can be used by an invidual user. Uses billing email for guests, and user ID for logged in users.', 'woocommerce'), 'desc_tip' => true, 'class' => 'short', 'type' => 'number', 'custom_attributes' => array('step' => 1, 'min' => 0), 'value' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : ''));
        echo '</div>';
        do_action('woocommerce_coupon_options_usage_limit');
        ?>
</div>
			<?php 
        do_action('woocommerce_coupon_data_panels');
        ?>
			<div class="clear"></div>
		</div>
		<?php 
    }
开发者ID:johnulist,项目名称:woocommerce,代码行数:101,代码来源:class-wc-meta-box-coupon-data.php

示例6: get_coupon

 /**
  * Get the coupon for the given ID
  *
  * @since 2.1
  * @param int $id the coupon ID
  * @param string $fields fields to include in response
  * @return array|WP_Error
  */
 public function get_coupon($id, $fields = null)
 {
     global $wpdb;
     $id = $this->validate_request($id, 'shop_coupon', 'read');
     if (is_wp_error($id)) {
         return $id;
     }
     // get the coupon code
     $code = $wpdb->get_var($wpdb->prepare("SELECT post_title FROM {$wpdb->posts} WHERE id = %s AND post_type = 'shop_coupon' AND post_status = 'publish'", $id));
     if (is_null($code)) {
         return new WP_Error('woocommerce_api_invalid_coupon_id', __('Invalid coupon ID', 'woocommerce'), array('status' => 404));
     }
     $coupon = new WC_Coupon($code);
     $coupon_post = get_post($coupon->get_id());
     $coupon_data = array('id' => $coupon->get_id(), 'code' => $coupon->get_code(), 'type' => $coupon->get_discount_type(), 'created_at' => $this->server->format_datetime($coupon_post->post_date_gmt), 'updated_at' => $this->server->format_datetime($coupon_post->post_modified_gmt), 'amount' => wc_format_decimal($coupon->get_amount(), 2), 'individual_use' => $coupon->get_individual_use(), 'product_ids' => array_map('absint', (array) $coupon->get_product_ids()), 'exclude_product_ids' => array_map('absint', (array) $coupon->get_excluded_product_ids()), 'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null, 'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null, 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), 'usage_count' => (int) $coupon->get_usage_count(), 'expiry_date' => $this->server->format_datetime($coupon->get_expiry_date()), 'enable_free_shipping' => $coupon->get_free_shipping(), 'product_category_ids' => array_map('absint', (array) $coupon->get_product_categories()), 'exclude_product_category_ids' => array_map('absint', (array) $coupon->get_excluded_product_categories()), 'exclude_sale_items' => $coupon->get_exclude_sale_items(), 'minimum_amount' => wc_format_decimal($coupon->get_minimum_amount(), 2), 'customer_emails' => $coupon->get_email_restrictions());
     return array('coupon' => apply_filters('woocommerce_api_coupon_response', $coupon_data, $coupon, $fields, $this->server));
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:25,代码来源:class-wc-api-coupons.php

示例7: format_posts_to_items

 /**
  * Format posts from WP_Query result to items in which each item contain
  * common properties of item, for instance `post_title` will be `code`.
  *
  * @since  2.5.0
  * @param  array $posts Array of post
  * @return array Items
  */
 protected function format_posts_to_items($posts)
 {
     $items = array();
     foreach ($posts as $post) {
         $coupon = new WC_Coupon();
         $coupon->read($post->ID);
         $coupon_usage_limit = $coupon->get_usage_limit();
         $coupon_usage_limit_per_user = $coupon->get_usage_limit_per_user();
         $coupon_date_expires = $coupon->get_date_expires();
         $items[] = array('id' => $post->ID, 'code' => $post->post_title, 'type' => $coupon->get_discount_type(), 'created_at' => $this->format_datetime($post->post_date_gmt), 'updated_at' => $this->format_datetime($post->post_modified_gmt), 'amount' => wc_format_decimal($coupon->get_amount(), 2), 'individual_use' => $coupon->get_individual_use(), 'product_ids' => implode(', ', is_array($coupon->get_product_ids()) ? $coupon->get_product_ids() : array()), 'exclude_product_ids' => implode(', ', is_array($coupon->get_excluded_product_ids()) ? $coupon->get_excluded_product_ids() : array()), 'usage_limit' => !empty($coupon_usage_limit) ? $coupon_usage_limit : null, 'usage_limit_per_user' => !empty($coupon_usage_limit_per_user) ? $coupon_usage_limit_per_user : null, 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), 'usage_count' => (int) $coupon->get_usage_count(), 'expiry_date' => !empty($coupon_date_expires) ? $this->format_datetime($coupon_date_expires) : null, 'free_shipping' => $coupon->get_free_shipping(), 'product_category_ids' => implode(', ', is_array($coupon->get_product_categories()) ? $coupon->get_product_categories() : array()), 'exclude_product_category_ids' => implode(', ', is_array($coupon->get_excluded_product_categories()) ? $coupon->get_excluded_product_categories() : array()), 'exclude_sale_items' => $coupon->get_exclude_sale_items(), 'minimum_amount' => wc_format_decimal($coupon->get_minimum_amount(), 2), 'maximum_amount' => wc_format_decimal($coupon->get_maximum_amount(), 2), 'customer_emails' => implode(', ', is_array($coupon->get_email_restrictions()) ? $coupon->get_email_restrictions() : array()), 'description' => $post->post_excerpt);
     }
     return $items;
 }
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:21,代码来源:class-wc-cli-coupon.php

示例8: get_coupon

 /**
  * Get the coupon for the given ID
  *
  * @since 2.1
  * @param int $id the coupon ID
  * @param string $fields fields to include in response
  * @return array|WP_Error
  */
 public function get_coupon($id, $fields = null)
 {
     try {
         $id = $this->validate_request($id, 'shop_coupon', 'read');
         if (is_wp_error($id)) {
             return $id;
         }
         // get the coupon code
         $code = wc_get_coupon_code_by_id($id);
         if (empty($code)) {
             throw new WC_API_Exception('woocommerce_api_invalid_coupon_id', __('Invalid coupon ID', 'woocommerce'), 404);
         }
         $coupon = new WC_Coupon($code);
         $coupon_post = get_post($coupon->get_id());
         $coupon_data = array('id' => $coupon->get_id(), 'code' => $coupon->get_code(), 'type' => $coupon->get_discount_type(), 'created_at' => $this->server->format_datetime($coupon_post->post_date_gmt), 'updated_at' => $this->server->format_datetime($coupon_post->post_modified_gmt), 'amount' => wc_format_decimal($coupon->get_amount(), 2), 'individual_use' => $coupon->get_individual_use(), 'product_ids' => array_map('absint', (array) $coupon->get_product_ids()), 'exclude_product_ids' => array_map('absint', (array) $coupon->get_excluded_product_ids()), 'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null, 'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null, 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), 'usage_count' => (int) $coupon->get_usage_count(), 'expiry_date' => $coupon->get_date_expires() ? $this->server->format_datetime($coupon->get_date_expires()) : null, 'enable_free_shipping' => $coupon->get_free_shipping(), 'product_category_ids' => array_map('absint', (array) $coupon->get_product_categories()), 'exclude_product_category_ids' => array_map('absint', (array) $coupon->get_excluded_product_categories()), 'exclude_sale_items' => $coupon->get_exclude_sale_items(), 'minimum_amount' => wc_format_decimal($coupon->get_minimum_amount(), 2), 'maximum_amount' => wc_format_decimal($coupon->get_maximum_amount(), 2), 'customer_emails' => $coupon->get_email_restrictions(), 'description' => $coupon_post->post_excerpt);
         return array('coupon' => apply_filters('woocommerce_api_coupon_response', $coupon_data, $coupon, $fields, $this->server));
     } catch (WC_API_Exception $e) {
         return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
     }
 }
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:28,代码来源:class-wc-api-coupons.php


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