Title: Cannot export Coupon ID or Code
Last modified: September 24, 2021

---

# Cannot export Coupon ID or Code

 *  Resolved [mawaybe](https://wordpress.org/support/users/mawaybe/)
 * (@mawaybe)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/cannot-export-coupon-id-or-code/)
 * Hi:
 * We need to export the coupon id and code to a POS system. It appears to work ‘
   sometimes’ using the following fields in WP All Export.
 * {_fcpdf_order_item_1536_coupon_id}
    {_fcpdf_order_item_1536_coupon_code}
 * So on one order we get this output:
 *  <_fcpdf_order_item_1536_coupon_id>1050006</_fcpdf_order_item_1536_coupon_id>
   
   <_fcpdf_order_item_1536_coupon_code>uwdu7</_fcpdf_order_item_1536_coupon_code
   >
 * But on the next order we get this output:
 *  <_fcpdf_order_item_1536_coupon_id/>
    <_fcpdf_order_item_1536_coupon_code/>
 * … just blank/empty records.
 * If we can get this working consistently we’ll upgrade to your Pro package.
 * Do you have any ideas what we are doing wrong? Could it be that one order has
   one coupon/gift card and the second has multiple?
 * Thanks for your help.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [rzepsen](https://wordpress.org/support/users/rzepsen/)
 * (@rzepsen)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/cannot-export-coupon-id-or-code/#post-14912607)
 * Hello Mawaybe
 * Thank you for your message
 * If the fields are empty it is likely that no voucher has been generated.
 * Please check whether the coupon/voucher has been generated in the cases you are
   reporting.
 * If the problem relates to an issued coupon, please let me know.
 * Best regards
 *  Plugin Support [rzepsen](https://wordpress.org/support/users/rzepsen/)
 * (@rzepsen)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/cannot-export-coupon-id-or-code/#post-14942178)
 * Hello [@mawaybe](https://wordpress.org/support/users/mawaybe/)
 * As we haven’t got any replies, I’m marking this topic as resolved for now.
 * Best regards
 *  Thread Starter [mawaybe](https://wordpress.org/support/users/mawaybe/)
 * (@mawaybe)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/cannot-export-coupon-id-or-code/#post-15016870)
 * Hi
 * Apologies for my delayed response.
 * I think the issue is when using WP All Export, I am inserting lines like
 * {_fcpdf_order_item_1536_coupon_id}
    {_fcpdf_order_item_1536_coupon_code}
 * But when I use an alternate export tool, I can see lots of ‘id’ and ‘code’ values:
 *     ```
       <Meta-_fcpdf_order_item_1536_coupon_code></Meta-_fcpdf_order_item_1536_coupon_code>
         <Meta-_fcpdf_order_item_1536_coupon_id></Meta-_fcpdf_order_item_1536_coupon_id>
         <Meta-_fcpdf_order_item_1549_coupon_code>qd10p</Meta-_fcpdf_order_item_1549_coupon_code>
         <Meta-_fcpdf_order_item_1549_coupon_id>1050042</Meta-_fcpdf_order_item_1549_coupon_id>
         <Meta-_fcpdf_order_item_1572_coupon_code></Meta-_fcpdf_order_item_1572_coupon_code>
         <Meta-_fcpdf_order_item_1572_coupon_id></Meta-_fcpdf_order_item_1572_coupon_id>
         <Meta-_fcpdf_order_item_1578_coupon_code></Meta-_fcpdf_order_item_1578_coupon_code>
         <Meta-_fcpdf_order_item_1578_coupon_id></Meta-_fcpdf_order_item_1578_coupon_id>
         <Meta-_fcpdf_order_item_1579_coupon_code></Meta-_fcpdf_order_item_1579_coupon_code>
         <Meta-_fcpdf_order_item_1579_coupon_id></Meta-_fcpdf_order_item_1579_coupon_id>
       ```
   
 * Is the plugin generating a unique meta field for every coupon? Is that why I 
   cannot include it in an XML export template – the ‘item_1578’ in the ‘_fcpdf_order_item_1578_coupon_id’
   keeps changing for every coupon so it cannot be templated?
 * Thanks for your help.
 *  Plugin Support [rzepsen](https://wordpress.org/support/users/rzepsen/)
 * (@rzepsen)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/cannot-export-coupon-id-or-code/#post-15029730)
 * Hello, [@mawaybe](https://wordpress.org/support/users/mawaybe/)
    Thank you for
   your message. Please take a look if the solution I am sending will be sufficient.
 *     ```
       $coupon_ids = [];
       $order_id = 100; // my order ID
       $order = wc_get_order( $order_id );
       if ( $order && ! empty( $order->get_items() ) ) {
          foreach ( $order->get_items() as $item ) {
             $coupon_id = get_post_meta( $order->get_id(), '_fcpdf_order_item_' . $item->get_id() . '_coupon_id', true );
             $coupon_ids[] = $coupon_id;
          }
       }
   
       var_dump( $coupon_ids );
       ```
   
 * Best regards
 *  Thread Starter [mawaybe](https://wordpress.org/support/users/mawaybe/)
 * (@mawaybe)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/cannot-export-coupon-id-or-code/#post-15030077)
 * Thank you very much – I will try this within the next 24 hours. Best.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Cannot export Coupon ID or Code’ is closed to new replies.

 * ![](https://ps.w.org/flexible-coupons/assets/icon-256x256.png?rev=2329191)
 * [Flexible PDF Coupons - Gift Cards & Vouchers for WooCommerce](https://wordpress.org/plugins/flexible-coupons/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/flexible-coupons/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/flexible-coupons/)
 * [Active Topics](https://wordpress.org/support/plugin/flexible-coupons/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/flexible-coupons/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/flexible-coupons/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [mawaybe](https://wordpress.org/support/users/mawaybe/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/cannot-export-coupon-id-or-code/#post-15030077)
 * Status: resolved