當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WC_Coupon::read_manual_coupon方法代碼示例

本文整理匯總了PHP中WC_Coupon::read_manual_coupon方法的典型用法代碼示例。如果您正苦於以下問題:PHP WC_Coupon::read_manual_coupon方法的具體用法?PHP WC_Coupon::read_manual_coupon怎麽用?PHP WC_Coupon::read_manual_coupon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WC_Coupon的用法示例。


在下文中一共展示了WC_Coupon::read_manual_coupon方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_read_manual_coupon

 /**
  * Developers can create manual coupons (code only). This test will make sure this works correctly
  * and some of our backwards compat handling works correctly as well.
  * @since 2.7.0
  */
 public function test_read_manual_coupon()
 {
     $code = 'manual_coupon_' . time();
     $coupon = new WC_Coupon($code);
     $coupon->read_manual_coupon($code, array('id' => true, 'type' => 'fixed_cart', 'amount' => 0, 'individual_use' => true, 'product_ids' => array(), 'exclude_product_ids' => array(), 'usage_limit' => '', 'usage_count' => '', 'expiry_date' => '', 'free_shipping' => false, 'product_categories' => array(), 'exclude_product_categories' => array(), 'exclude_sale_items' => false, 'minimum_amount' => '', 'maximum_amount' => 100, 'customer_email' => ''));
     $this->assertEquals($code, $coupon->get_code());
     $this->assertEquals(true, $coupon->get_individual_use());
     $this->assertEquals(100, $coupon->get_maximum_amount());
     /**
      * test our back compat logic: passing in product_ids/exclude_product_ids in as strings
      * and passing free_shipping, exclude_sale_items, and individual_use in as yes|no strings.
      * setting these values this way will also throw a deprecated notice so we will let
      * PHPUnit know that its okay to continue.
      */
     $legacy_keys = array('product_ids', 'exclude_product_ids', 'individual_use', 'free_shipping', 'exclude_sale_items');
     $this->expected_doing_it_wrong = array_merge($this->expected_doing_it_wrong, $legacy_keys);
     $code = 'bc_manual_coupon_' . time();
     $coupon = new WC_Coupon($code);
     $coupon->read_manual_coupon($code, array('id' => true, 'type' => 'fixed_cart', 'amount' => 0, 'individual_use' => 'yes', 'product_ids' => '', 'exclude_product_ids' => '5,6', 'usage_limit' => '', 'usage_count' => '', 'expiry_date' => '', 'free_shipping' => 'no', 'product_categories' => array(), 'exclude_product_categories' => array(), 'exclude_sale_items' => 'no', 'minimum_amount' => '', 'maximum_amount' => 100, 'customer_email' => ''));
     $this->assertEquals($code, $coupon->get_code());
     $this->assertEquals(true, $coupon->get_individual_use());
     $this->assertEquals(false, $coupon->get_free_shipping());
     $this->assertEquals(false, $coupon->get_exclude_sale_items());
     $this->assertEquals(array(5, 6), $coupon->get_excluded_product_ids());
     $this->assertEquals(array(), $coupon->get_product_ids());
 }
開發者ID:Korkey128k,項目名稱:woocommerce,代碼行數:31,代碼來源:crud.php


注:本文中的WC_Coupon::read_manual_coupon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。