您可以創建的800 diferent數組中的鍵,只是做一個foreach循環重複該過程,你有這樣的OP貼裏面的這個
forehach ($your_800_array as $coupon_code){
//the code from the page you posted
$amount = '10'; // Amount
$discount_type = 'fixed_cart'; // Type: fixed_cart, percent, fixed_product, percent_product
$coupon = array(
'post_title' => $coupon_code,
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'shop_coupon'
);
$new_coupon_id = wp_insert_post($coupon);
// Add meta
update_post_meta($new_coupon_id, 'discount_type', $discount_type);
update_post_meta($new_coupon_id, 'coupon_amount', $amount);
update_post_meta($new_coupon_id, 'individual_use', 'no');
update_post_meta($new_coupon_id, 'product_ids', '');
update_post_meta($new_coupon_id, 'exclude_product_ids', '');
update_post_meta($new_coupon_id, 'usage_limit', '');
update_post_meta($new_coupon_id, 'expiry_date', '');
update_post_meta($new_coupon_id, 'apply_before_tax', 'yes');
update_post_meta($new_coupon_id, 'free_shipping', 'no');
}
(使用的代碼陣列上的每一個不同的密鑰沒有經過實際測試)
您是否瞭解該產品[智能優惠券](http://www.woothemes.com/products/smart-coupons/)。使用此產品,您可以創建許多獨特的優惠券代碼,只需點擊幾下即可導入WooCommerce中的所有優惠券,並可將生成的優惠券代碼導出爲CSV文件。此產品爲WooCommerce優惠券提供了許多功能。在產品文檔中,您無法找到自動生成和導入的內容,因爲產品文檔不會很長時間更新。 –
感謝您的建議,它確實看起來可行,但我對添加如此龐大的一系列功能和另一個插件持謹慎態度,因爲一個所需功能的複雜性如此之高並不理想。 –