1. <i id='X324y'><tr id='X324y'><dt id='X324y'><q id='X324y'><span id='X324y'><b id='X324y'><form id='X324y'><ins id='X324y'></ins><ul id='X324y'></ul><sub id='X324y'></sub></form><legend id='X324y'></legend><bdo id='X324y'><pre id='X324y'><center id='X324y'></center></pre></bdo></b><th id='X324y'></th></span></q></dt></tr></i><div id='X324y'><tfoot id='X324y'></tfoot><dl id='X324y'><fieldset id='X324y'></fieldset></dl></div>
    1. <small id='X324y'></small><noframes id='X324y'>

      <tfoot id='X324y'></tfoot>
        <bdo id='X324y'></bdo><ul id='X324y'></ul>
    2. <legend id='X324y'><style id='X324y'><dir id='X324y'><q id='X324y'></q></dir></style></legend>

      WooCommerce 优惠券如何存储在数据库中?

      时间:2023-10-25
      <tfoot id='3URgu'></tfoot>

      <i id='3URgu'><tr id='3URgu'><dt id='3URgu'><q id='3URgu'><span id='3URgu'><b id='3URgu'><form id='3URgu'><ins id='3URgu'></ins><ul id='3URgu'></ul><sub id='3URgu'></sub></form><legend id='3URgu'></legend><bdo id='3URgu'><pre id='3URgu'><center id='3URgu'></center></pre></bdo></b><th id='3URgu'></th></span></q></dt></tr></i><div id='3URgu'><tfoot id='3URgu'></tfoot><dl id='3URgu'><fieldset id='3URgu'></fieldset></dl></div>

        <tbody id='3URgu'></tbody>
        • <bdo id='3URgu'></bdo><ul id='3URgu'></ul>
        • <small id='3URgu'></small><noframes id='3URgu'>

          • <legend id='3URgu'><style id='3URgu'><dir id='3URgu'><q id='3URgu'></q></dir></style></legend>

                本文介绍了WooCommerce 优惠券如何存储在数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                每次我有新的注册时,我都需要运行一个脚本来检查我的优惠券,但我找不到优惠券生成器 (WooCommerce) 中优惠券的存储位置.

                I need to run a script to check my coupons every time I have a new register, but I can't find where the coupons from coupon generator (WooCommerce) are stored.

                推荐答案

                WooCommerce 优惠券存储在 wp_posts 表中,post_type =>'shop_coupon'.并且所有关联的数据都存储在wp_postmeta表中.

                WooCommerce Coupon are stored in wp_posts table with post_type => 'shop_coupon'. And all the associated data are stored in wp_postmeta table.

                您可以使用此 MySQL 查询来获取所有 Coupon:

                You can use this MySQL query to get all the Coupon:

                SELECT * FROM `wp_posts` WHERE `post_type` = 'shop_coupon' ORDER BY `ID` DESC
                

                这会得到所有的优惠券

                SELECT p.`ID`, 
                       p.`post_title`   AS coupon_code, 
                       p.`post_excerpt` AS coupon_description, 
                       Max(CASE WHEN pm.meta_key = 'discount_type'      AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS discount_type,          -- Discount type 
                       Max(CASE WHEN pm.meta_key = 'coupon_amount'      AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS coupon_amount,          -- Coupon amount 
                       Max(CASE WHEN pm.meta_key = 'free_shipping'      AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS free_shipping,          -- Allow free shipping 
                       Max(CASE WHEN pm.meta_key = 'expiry_date'        AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS expiry_date,                -- Coupon expiry date 
                       Max(CASE WHEN pm.meta_key = 'minimum_amount'     AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS minimum_amount,         -- Minimum spend 
                       Max(CASE WHEN pm.meta_key = 'maximum_amount'     AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS maximum_amount,         -- Maximum spend 
                       Max(CASE WHEN pm.meta_key = 'individual_use'     AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS individual_use,         -- Individual use only 
                       Max(CASE WHEN pm.meta_key = 'exclude_sale_items' AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS exclude_sale_items,         -- Exclude sale items 
                       Max(CASE WHEN pm.meta_key = 'product_ids'    AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS product_ids,                -- Products 
                       Max(CASE WHEN pm.meta_key = 'exclude_product_ids'AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS exclude_product_ids,        -- Exclude products 
                       Max(CASE WHEN pm.meta_key = 'product_categories' AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS product_categories,             -- Product categories 
                       Max(CASE WHEN pm.meta_key = 'exclude_product_categories' AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS exclude_product_categories,-- Exclude Product categories 
                       Max(CASE WHEN pm.meta_key = 'customer_email'     AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS customer_email,         -- Email restrictions 
                       Max(CASE WHEN pm.meta_key = 'usage_limit'    AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS usage_limit,                -- Usage limit per coupon 
                       Max(CASE WHEN pm.meta_key = 'usage_limit_per_user'   AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS usage_limit_per_user,   -- Usage limit per user 
                       Max(CASE WHEN pm.meta_key = 'usage_count'    AND  p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS total_usaged                   -- Usage count 
                FROM   `wp_posts` AS p 
                       INNER JOIN `wp_postmeta` AS pm ON  p.`ID` = pm.`post_id` 
                WHERE  p.`post_type` = 'shop_coupon' 
                       AND p.`post_status` = 'publish' 
                GROUP  BY p.`ID` 
                ORDER  BY p.`ID` ASC;
                

                参考:MySQL Query to Get所有优惠券

                这篇关于WooCommerce 优惠券如何存储在数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:零 SQL 死锁设计 - 任何编码模式? 下一篇:以编程方式更新 Woocommerce 订单

                相关文章

                  1. <legend id='xlmM7'><style id='xlmM7'><dir id='xlmM7'><q id='xlmM7'></q></dir></style></legend>
                    • <bdo id='xlmM7'></bdo><ul id='xlmM7'></ul>
                  2. <i id='xlmM7'><tr id='xlmM7'><dt id='xlmM7'><q id='xlmM7'><span id='xlmM7'><b id='xlmM7'><form id='xlmM7'><ins id='xlmM7'></ins><ul id='xlmM7'></ul><sub id='xlmM7'></sub></form><legend id='xlmM7'></legend><bdo id='xlmM7'><pre id='xlmM7'><center id='xlmM7'></center></pre></bdo></b><th id='xlmM7'></th></span></q></dt></tr></i><div id='xlmM7'><tfoot id='xlmM7'></tfoot><dl id='xlmM7'><fieldset id='xlmM7'></fieldset></dl></div>

                    <small id='xlmM7'></small><noframes id='xlmM7'>

                  3. <tfoot id='xlmM7'></tfoot>