VariableProductTitle
8 years ago
.gitkeep
8 years ago
WpaeInvalidPhpException.php
8 years ago
WpaeInvalidStringException.php
8 years ago
WpaeMethodNotFoundException.php
8 years ago
WpaePhpInterpreterErrorHandler.php
8 years ago
WpaeString.php
8 years ago
WpaeTooMuchRecursionException.php
8 years ago
WpaeXmlProcessor.php
8 years ago
XmlCsvExport.php
8 years ago
XmlExportACF.php
8 years ago
XmlExportComment.php
8 years ago
XmlExportCpt.php
8 years ago
XmlExportEngine.php
8 years ago
XmlExportFiltering.php
8 years ago
XmlExportMediaGallery.php
8 years ago
XmlExportTaxonomy.php
8 years ago
XmlExportUser.php
8 years ago
XmlExportWooCommerce.php
8 years ago
XmlExportWooCommerceCoupon.php
8 years ago
XmlExportWooCommerceOrder.php
8 years ago
XmlGoogleMerchants.php
8 years ago
XmlSpec.php
8 years ago
XmlExportWooCommerceCoupon.php
198 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! class_exists('XmlExportWooCommerceCoupon') ) |
| 4 | { |
| 5 | final class XmlExportWooCommerceCoupon |
| 6 | { |
| 7 | public static $is_active = true; |
| 8 | |
| 9 | public $init_fields = array( |
| 10 | array( |
| 11 | 'name' => 'Coupon ID', |
| 12 | 'type' => 'id', |
| 13 | 'options' => '', |
| 14 | 'label' => 'id' |
| 15 | ), |
| 16 | array( |
| 17 | 'name' => 'Coupon Code', |
| 18 | 'type' => 'title', |
| 19 | 'options' => '', |
| 20 | 'label' => 'title' |
| 21 | ), |
| 22 | array( |
| 23 | 'name' => 'Expiry Date', |
| 24 | 'type' => 'cf', |
| 25 | 'options' => '', |
| 26 | 'label' => 'expiry_date' |
| 27 | ) |
| 28 | ); |
| 29 | |
| 30 | public $default_fields = array( |
| 31 | array( |
| 32 | 'name' => 'Coupon ID', |
| 33 | 'type' => 'id', |
| 34 | 'label' => 'id' |
| 35 | ), |
| 36 | array( |
| 37 | 'name' => 'Coupon Code', |
| 38 | 'type' => 'title', |
| 39 | 'label' => 'title' |
| 40 | ), |
| 41 | array( |
| 42 | 'name' => 'Coupon Description', |
| 43 | 'type' => 'excerpt', |
| 44 | 'label' => 'excerpt' |
| 45 | ), |
| 46 | array( |
| 47 | 'name' => 'Discount Type', |
| 48 | 'type' => 'cf', |
| 49 | 'label' => 'discount_type' |
| 50 | ), |
| 51 | array( |
| 52 | 'name' => 'Coupon Amount', |
| 53 | 'type' => 'cf', |
| 54 | 'label' => 'coupon_amount' |
| 55 | ), |
| 56 | array( |
| 57 | 'name' => 'Expiry Date', |
| 58 | 'type' => 'cf', |
| 59 | 'label' => 'expiry_date' |
| 60 | ), |
| 61 | array( |
| 62 | 'name' => 'Free Shipping', |
| 63 | 'type' => 'cf', |
| 64 | 'label' => 'free_shipping' |
| 65 | ), |
| 66 | array( |
| 67 | 'name' => 'Exclude Sale Items', |
| 68 | 'type' => 'cf', |
| 69 | 'label' => 'exclude_sale_items' |
| 70 | ) |
| 71 | ); |
| 72 | |
| 73 | public $other_fields = array( |
| 74 | array( |
| 75 | 'label' => 'status', |
| 76 | 'name' => 'Status', |
| 77 | 'type' => 'status' |
| 78 | ), |
| 79 | array( |
| 80 | 'label' => 'author', |
| 81 | 'name' => 'Author', |
| 82 | 'type' => 'author' |
| 83 | ), |
| 84 | array( |
| 85 | 'label' => 'slug', |
| 86 | 'name' => 'Slug', |
| 87 | 'type' => 'slug' |
| 88 | ), |
| 89 | array( |
| 90 | 'label' => 'date', |
| 91 | 'name' => 'Date', |
| 92 | 'type' => 'date' |
| 93 | ), |
| 94 | array( |
| 95 | 'label' => 'post_type', |
| 96 | 'name' => 'Post Type', |
| 97 | 'type' => 'post_type' |
| 98 | ) |
| 99 | ); |
| 100 | |
| 101 | |
| 102 | private $_coupon_data = array(); |
| 103 | |
| 104 | public function __construct() |
| 105 | { |
| 106 | if ( ! class_exists('WooCommerce') |
| 107 | or ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('shop_coupon', XmlExportEngine::$post_types) ) |
| 108 | or ( XmlExportEngine::$exportOptions['export_type'] == 'advanced' and strpos(XmlExportEngine::$exportOptions['wp_query'], 'shop_coupon') === false ) ) { |
| 109 | self::$is_active = false; |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | self::$is_active = true; |
| 114 | |
| 115 | $this->_coupon_data = array( |
| 116 | 'discount_type', 'coupon_amount', 'expiry_date', 'free_shipping', 'exclude_sale_items' |
| 117 | ); |
| 118 | |
| 119 | add_filter("wp_all_export_default_fields", array( &$this, "filter_default_fields"), 10, 1); |
| 120 | add_filter("wp_all_export_other_fields", array( &$this, "filter_other_fields"), 10, 1); |
| 121 | add_filter("wp_all_export_available_data", array( &$this, "filter_available_data"), 10, 1); |
| 122 | add_filter("wp_all_export_available_sections", array( &$this, "filter_available_sections" ), 10, 1); |
| 123 | add_filter("wp_all_export_init_fields", array( &$this, "filter_init_fields"), 10, 1); |
| 124 | |
| 125 | } |
| 126 | |
| 127 | // [FILTERS] |
| 128 | |
| 129 | /** |
| 130 | * |
| 131 | * Filter Init Fields |
| 132 | * |
| 133 | */ |
| 134 | public function filter_init_fields($init_fields){ |
| 135 | return $this->init_fields; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * |
| 140 | * Filter Default Fields |
| 141 | * |
| 142 | */ |
| 143 | public function filter_default_fields($default_fields){ |
| 144 | return $this->default_fields; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * |
| 149 | * Filter Other Fields |
| 150 | * |
| 151 | */ |
| 152 | public function filter_other_fields($other_fields){ |
| 153 | return $this->other_fields; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * |
| 158 | * Filter Available Data |
| 159 | * |
| 160 | */ |
| 161 | public function filter_available_data($available_data){ |
| 162 | |
| 163 | $available_data['existing_meta_keys'] = array_merge($available_data['other_fields'], $available_data['existing_meta_keys']); |
| 164 | |
| 165 | return $available_data; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * |
| 170 | * Filter Sections in Available Data |
| 171 | * |
| 172 | */ |
| 173 | public function filter_available_sections($sections){ |
| 174 | unset($sections['media']); |
| 175 | unset($sections['other']); |
| 176 | $sections['cf']['title'] = __("Other", "wp_all_export_plugin"); |
| 177 | return $sections; |
| 178 | } |
| 179 | |
| 180 | // [\FILTERS] |
| 181 | |
| 182 | public function init( & $existing_meta_keys = array() ){ |
| 183 | |
| 184 | if ( ! self::$is_active ) return; |
| 185 | |
| 186 | if ( ! empty($existing_meta_keys) ) |
| 187 | { |
| 188 | foreach ($existing_meta_keys as $key => $record_meta_key) |
| 189 | { |
| 190 | if ( in_array($record_meta_key, $this->_coupon_data) ) |
| 191 | { |
| 192 | unset($existing_meta_keys[$key]); |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | } |