| 1 |
<?php |
| 2 |
/** |
| 3 |
* WP Ultimate Exporter plugin file. |
| 4 |
* |
| 5 |
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Smackcoders\SMEXP; |
| 9 |
use Smackcoders\SMEXP\WC_Coupon; |
| 10 |
if ( ! defined( 'ABSPATH' ) ) |
| 11 |
exit; // Exit if accessed directly |
| 12 |
|
| 13 |
/** |
| 14 |
* Class WooCommerceExport |
| 15 |
* @package Smackcoders\WCSV |
| 16 |
*/ |
| 17 |
|
| 18 |
require_once dirname(__FILE__) . '/ElementorExport.php'; |
| 19 |
|
| 20 |
|
| 21 |
class WooCommerceExport extends ExportExtension{ |
| 22 |
|
| 23 |
protected static $instance = null,$mapping_instance,$export_handler,$export_instance,$post_export; |
| 24 |
public $offset = 0; |
| 25 |
public $limit = 1000; |
| 26 |
public $totalRowCount; |
| 27 |
public static function getInstance() { |
| 28 |
if ( null == self::$instance ) { |
| 29 |
self::$instance = new self; |
| 30 |
WooCommerceExport::$export_instance = ExportExtension::getInstance(); |
| 31 |
WooCommerceExport::$post_export = PostExport::getInstance(); |
| 32 |
} |
| 33 |
return self::$instance; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* WooCommerceExport constructor. |
| 38 |
*/ |
| 39 |
public function __construct() { |
| 40 |
$this->plugin = Plugin::getInstance(); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Export woocommerce orders |
| 45 |
* @param $id |
| 46 |
* @param $type |
| 47 |
* @param $optional |
| 48 |
* @return bool |
| 49 |
*/ |
| 50 |
public function getCouponsData($id, $type, $optionalType){ |
| 51 |
$coupon_id = $id; |
| 52 |
$c = new \WC_Coupon($coupon_id); |
| 53 |
$DiscountType = $c->get_discount_type(); |
| 54 |
$CouponAmount = $c->get_amount(); |
| 55 |
$IndividualUse = $c->get_individual_use(); |
| 56 |
$ProductIDs = $c->get_product_ids(); |
| 57 |
$ExcludeProductIDs = $c->get_excluded_product_ids(); |
| 58 |
$UsageLimit = $c->get_usage_limit(); |
| 59 |
$UsageLimitPerUser = $c->get_usage_limit_per_user(); |
| 60 |
$LimitUsageToXItems = $c->get_limit_usage_to_x_items(); |
| 61 |
$ExpiryDate = $c->get_date_expires(); |
| 62 |
$FreeShipping = $c->get_free_shipping(); |
| 63 |
$ExcludeSaleItems = $c->get_exclude_sale_items(); |
| 64 |
$MinimumAmount = $c->get_minimum_amount(); |
| 65 |
$MaximumAmount = $c->get_maximum_amount(); |
| 66 |
$CustomerEmail = $c->get_email_restrictions(); |
| 67 |
$ExcludedProductCategories = $c->get_excluded_product_categories(); |
| 68 |
$ProductCategories = $c->get_product_categories(); |
| 69 |
|
| 70 |
$product_Ids = array(); |
| 71 |
$Exclude_Product_IDs =array(); |
| 72 |
$product_cat = array(); |
| 73 |
$exclude_cat = array(); |
| 74 |
$cus_email = array(); |
| 75 |
foreach ($ProductCategories as $p_IDs) { |
| 76 |
$product_cat[] = $p_IDs; |
| 77 |
} |
| 78 |
foreach ($ExcludedProductCategories as $p_IDs) { |
| 79 |
$exclude_cat[] = $p_IDs; |
| 80 |
} |
| 81 |
|
| 82 |
foreach ($CustomerEmail as $p_IDs) { |
| 83 |
$cus_email[] = $p_IDs; |
| 84 |
} |
| 85 |
|
| 86 |
foreach ($ProductIDs as $p_IDs) { |
| 87 |
$product_Ids[] = $p_IDs; |
| 88 |
} |
| 89 |
foreach($ExcludeProductIDs as $Exclude_PIds){ |
| 90 |
$Exclude_Product_IDs[] = $Exclude_PIds; |
| 91 |
} |
| 92 |
|
| 93 |
WooCommerceExport::$export_instance->data[$id]['exclude_product_categories'] = !empty($exclude_cat) ? implode(',', $exclude_cat) : ''; |
| 94 |
WooCommerceExport::$export_instance->data[$id]['customer_email'] = !empty($cus_email) ? implode(',', $cus_email) : ''; |
| 95 |
WooCommerceExport::$export_instance->data[$id]['product_categories'] = !empty($product_cat) ? implode(',', $product_cat) : ''; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
WooCommerceExport::$export_instance->data[$id]['discount_type'] = $DiscountType; |
| 100 |
WooCommerceExport::$export_instance->data[$id]['coupon_amount'] = $CouponAmount; |
| 101 |
WooCommerceExport::$export_instance->data[$id]['individual_use'] = $IndividualUse ? 'yes' : 'no'; |
| 102 |
WooCommerceExport::$export_instance->data[$id]['usage_limit'] = $UsageLimit; |
| 103 |
WooCommerceExport::$export_instance->data[$id]['usage_limit_per_user'] = $UsageLimitPerUser; |
| 104 |
WooCommerceExport::$export_instance->data[$id]['limit_usage_to_x_items'] = $LimitUsageToXItems; |
| 105 |
WooCommerceExport::$export_instance->data[$id]['expiry_date'] = $ExpiryDate ? $ExpiryDate->date('Y-m-d H:i:s') : null; |
| 106 |
WooCommerceExport::$export_instance->data[$id]['free_shipping'] = $FreeShipping ? 'yes' : 'no'; |
| 107 |
WooCommerceExport::$export_instance->data[$id]['exclude_sale_items'] = $ExcludeSaleItems ? 'yes' : 'no'; |
| 108 |
WooCommerceExport::$export_instance->data[$id]['minimum_amount'] = $MinimumAmount; |
| 109 |
WooCommerceExport::$export_instance->data[$id]['maximum_amount'] = $MaximumAmount; |
| 110 |
// Handle the product IDs and excluded product IDs with implode only if they are not empty |
| 111 |
WooCommerceExport::$export_instance->data[$id]['product_ids'] = !empty($product_Ids) ? implode(',', $product_Ids) : ''; |
| 112 |
WooCommerceExport::$export_instance->data[$id]['exclude_product_ids'] = !empty($Exclude_Product_IDs) ? implode(',', $Exclude_Product_IDs) : ''; |
| 113 |
|
| 114 |
} |
| 115 |
public function getWooComOrderData($id, $type, $optional) |
| 116 |
{ |
| 117 |
$order = wc_get_order($id); |
| 118 |
$order_data = $order->get_data(); |
| 119 |
$orderid = self::$export_instance->data[$id]['ID']; |
| 120 |
WooCommerceExport::$export_instance->data[$id]['ORDERID'] = $orderid; |
| 121 |
//fetch the order data |
| 122 |
$date_created_object = $order_data['date_created']; |
| 123 |
$formatted_date_time = $date_created_object->date('m/d/Y H:i:s'); |
| 124 |
WooCommerceExport::$export_instance->data[$id]['order_date'] = $formatted_date_time; |
| 125 |
$customer_note = $order_data['customer_note']; |
| 126 |
WooCommerceExport::$export_instance->data[$id]['customer_note'] = $customer_note; |
| 127 |
$billing_details = $order_data['billing']; |
| 128 |
$order_status = $order_data['status']; |
| 129 |
WooCommerceExport::$export_instance->data[$id]['order_status'] = 'wc-'.$order_status; |
| 130 |
$_billing_first_name = $billing_details['first_name']; |
| 131 |
WooCommerceExport::$export_instance->data[$id]['_billing_first_name'] = $_billing_first_name; |
| 132 |
$_billing_last_name = $billing_details['last_name']; |
| 133 |
WooCommerceExport::$export_instance->data[$id]['_billing_last_name'] = $_billing_last_name; |
| 134 |
$_billing_company = $billing_details['company']; |
| 135 |
WooCommerceExport::$export_instance->data[$id]['_billing_company'] = $_billing_company; |
| 136 |
$_billing_address_1 = $billing_details['address_1']; |
| 137 |
WooCommerceExport::$export_instance->data[$id]['_billing_address_1'] = $_billing_address_1; |
| 138 |
$_billing_address_2 = $billing_details['address_2']; |
| 139 |
WooCommerceExport::$export_instance->data[$id]['_billing_address_2'] = $_billing_address_2; |
| 140 |
$_billing_city = $billing_details['city']; |
| 141 |
WooCommerceExport::$export_instance->data[$id]['_billing_city'] = $_billing_city; |
| 142 |
$_billing_state = $billing_details['state']; |
| 143 |
WooCommerceExport::$export_instance->data[$id]['_billing_state'] = $_billing_state; |
| 144 |
$_billing_postcode = $billing_details['postcode']; |
| 145 |
WooCommerceExport::$export_instance->data[$id]['_billing_postcode'] = $_billing_postcode; |
| 146 |
$_billing_country = $billing_details['country']; |
| 147 |
WooCommerceExport::$export_instance->data[$id]['_billing_country'] = $_billing_country; |
| 148 |
$_order_currency = $order_data['currency']; |
| 149 |
WooCommerceExport::$export_instance->data[$id]['_order_currency'] = $_order_currency; |
| 150 |
$_order_shipping_tax = $order_data['shipping_tax']; |
| 151 |
WooCommerceExport::$export_instance->data[$id]['_order_shipping_tax'] = $_order_shipping_tax; |
| 152 |
$_order_shipping = $order->get_shipping_total(); |
| 153 |
WooCommerceExport::$export_instance->data[$id]['_order_shipping'] = $_order_shipping; |
| 154 |
$_order_tax = $order_data['cart_tax']; |
| 155 |
WooCommerceExport::$export_instance->data[$id]['_order_tax'] = $_order_tax; |
| 156 |
$_customer_user = $order_data['customer_id']; |
| 157 |
if($_customer_user != 0){ |
| 158 |
$user_data = get_userdata($_customer_user); |
| 159 |
$user_email = $user_data->user_email; |
| 160 |
WooCommerceExport::$export_instance->data[$id]['_customer_user'] = $user_email ; |
| 161 |
} |
| 162 |
$_billing_email = $billing_details['email']; |
| 163 |
WooCommerceExport::$export_instance->data[$id]['_billing_email'] = $_billing_email; |
| 164 |
|
| 165 |
$_billing_phone = $billing_details['phone']; |
| 166 |
WooCommerceExport::$export_instance->data[$id]['_billing_phone'] = $_billing_phone; |
| 167 |
|
| 168 |
$_shipping_first_name = $order_data['shipping']['first_name']; |
| 169 |
WooCommerceExport::$export_instance->data[$id]['_shipping_first_name'] = $_shipping_first_name; |
| 170 |
|
| 171 |
$_shipping_last_name = $order_data['shipping']['last_name']; |
| 172 |
WooCommerceExport::$export_instance->data[$id]['_shipping_last_name'] = $_shipping_last_name; |
| 173 |
|
| 174 |
$_shipping_company = $order_data['shipping']['company']; |
| 175 |
WooCommerceExport::$export_instance->data[$id]['_shipping_company'] = $_shipping_company; |
| 176 |
|
| 177 |
$_shipping_address_1 = $order_data['shipping']['address_1']; |
| 178 |
WooCommerceExport::$export_instance->data[$id]['_shipping_address_1'] = $_shipping_address_1; |
| 179 |
|
| 180 |
$_shipping_address_2 = $order_data['shipping']['address_2']; |
| 181 |
WooCommerceExport::$export_instance->data[$id]['_shipping_address_2'] = $_shipping_address_2; |
| 182 |
|
| 183 |
$_shipping_city = $order_data['shipping']['city']; |
| 184 |
WooCommerceExport::$export_instance->data[$id]['_shipping_city'] = $_shipping_city; |
| 185 |
|
| 186 |
$_shipping_state = $order_data['shipping']['state']; |
| 187 |
WooCommerceExport::$export_instance->data[$id]['_shipping_state'] = $_shipping_state; |
| 188 |
|
| 189 |
$_shipping_postcode = $order_data['shipping']['postcode']; |
| 190 |
WooCommerceExport::$export_instance->data[$id]['_shipping_postcode'] = $_shipping_postcode; |
| 191 |
|
| 192 |
$_shipping_country = $order_data['shipping']['country']; |
| 193 |
WooCommerceExport::$export_instance->data[$id]['_shipping_country'] = $_shipping_country; |
| 194 |
|
| 195 |
$_shipping_phone = $order_data['shipping']['phone']; |
| 196 |
WooCommerceExport::$export_instance->data[$id]['_shipping_phone'] = $_shipping_phone; |
| 197 |
|
| 198 |
$_order_total = $order_data['total']; |
| 199 |
WooCommerceExport::$export_instance->data[$id]['_order_total'] = $_order_total; |
| 200 |
|
| 201 |
$_cart_discount = $order_data['discount_total']; |
| 202 |
WooCommerceExport::$export_instance->data[$id]['_cart_discount'] = $_cart_discount; |
| 203 |
|
| 204 |
$_cart_discount_tax = $order_data['discount_tax']; |
| 205 |
WooCommerceExport::$export_instance->data[$id]['_cart_discount_tax'] = $_cart_discount_tax; |
| 206 |
|
| 207 |
$_payment_method = $order_data['payment_method']; |
| 208 |
WooCommerceExport::$export_instance->data[$id]['_payment_method'] = $_payment_method; |
| 209 |
|
| 210 |
$_recorded_sales= $order_data['recorded_sales']; |
| 211 |
if($_recorded_sales > 0){ |
| 212 |
$_recorded_sales = 'yes'; |
| 213 |
}else{ |
| 214 |
$_recorded_sales = 'no'; |
| 215 |
} |
| 216 |
WooCommerceExport::$export_instance->data[$id]['recorded_sales'] = $_recorded_sales; |
| 217 |
|
| 218 |
$_payment_method_title = $order_data['payment_method_title']; |
| 219 |
WooCommerceExport::$export_instance->data[$id]['_payment_method_title'] = $_payment_method_title; |
| 220 |
|
| 221 |
$_transaction_id = $order_data['transaction_id']; |
| 222 |
WooCommerceExport::$export_instance->data[$id]['_transaction_id'] = $_transaction_id; |
| 223 |
$line_items = $order->get_items(); |
| 224 |
$mycoupon = $order->get_coupons(); |
| 225 |
|
| 226 |
if (!empty($mycoupon)) { |
| 227 |
foreach ($mycoupon as $coupon) { |
| 228 |
$coupon_code = $coupon->get_code(); |
| 229 |
} |
| 230 |
} |
| 231 |
if(!empty($line_items)){ |
| 232 |
foreach ($line_items as $item_id => $item) { |
| 233 |
$item_names[] = $item->get_name(); |
| 234 |
$product_type[] = $item->get_type(); |
| 235 |
$variation_id[] = $item->get_variation_id(); |
| 236 |
$product_id[] = $item->get_product_id(); |
| 237 |
$subtotal[] = $item->get_subtotal(); |
| 238 |
$subtotal_tax[] = $item->get_subtotal_tax(); |
| 239 |
$total[] = $item->get_total(); |
| 240 |
$total_tax[] = $item->get_total_tax(); |
| 241 |
$item_tax_data[] = $item->get_taxes(); |
| 242 |
if (!empty($item_tax_data) && is_array($item_tax_data)) { |
| 243 |
if(!empty($item_tax_data[0]['total']) || !empty($item_tax_data[0]['subtotal'])){ |
| 244 |
$line_tax[] = implode(',', $item_tax_data[0]['total']); |
| 245 |
$line_tax[] = implode(',', $item_tax_data[0]['subtotal']); |
| 246 |
}else{ |
| 247 |
$line_tax = array(); |
| 248 |
} |
| 249 |
} |
| 250 |
$tax_class[] = $item->get_tax_class(); |
| 251 |
$quantity[] = $item->get_quantity(); |
| 252 |
} |
| 253 |
if (!empty($coupon_code)) { |
| 254 |
$item_names[] = $coupon_code; |
| 255 |
$product_type[] = 'coupon'; |
| 256 |
} |
| 257 |
//itemdata |
| 258 |
self::$export_instance->data[$id]['item_name'] = implode(',', $item_names); |
| 259 |
self::$export_instance->data[$id]['item_type'] = implode(',', $product_type); |
| 260 |
self::$export_instance->data[$id]['item_variation_id'] = implode(',', $variation_id); |
| 261 |
self::$export_instance->data[$id]['item_product_id'] = implode(',', $product_id); |
| 262 |
self::$export_instance->data[$id]['item_line_subtotal'] = implode(',', $subtotal); |
| 263 |
self::$export_instance->data[$id]['item_line_subtotal_tax'] = implode(',', $subtotal_tax); |
| 264 |
self::$export_instance->data[$id]['item_line_total'] = implode(',', $total); |
| 265 |
self::$export_instance->data[$id]['item_line_tax'] = implode(',', $total_tax); |
| 266 |
self::$export_instance->data[$id]['item_line_tax_data'] = implode(',', $line_tax); |
| 267 |
self::$export_instance->data[$id]['item_tax_class'] = implode(',', $tax_class); |
| 268 |
self::$export_instance->data[$id]['item_qty'] = implode(',', $quantity); |
| 269 |
} |
| 270 |
//fee data |
| 271 |
$fees = $order->get_fees(); |
| 272 |
if(!empty($fees)){ |
| 273 |
foreach ($fees as $fee) { |
| 274 |
$fee_name[] = $fee->get_name(); |
| 275 |
$fee_type[] = $fee->get_type(); // Assuming there's a get_type() method; check the documentation |
| 276 |
$fee_tax_class[] = $fee->get_tax_class(); |
| 277 |
$fee_line_total[] = $fee->get_total(); |
| 278 |
$fee_line_tax[] = $fee->get_total_tax(); |
| 279 |
// $fee_line_subtotal[] = $fee->get_subtotal(); |
| 280 |
// $fee_line_subtotal_tax[] = $fee->get_subtotal_tax(); |
| 281 |
$tax_data = $fee->get_taxes(); |
| 282 |
if(!empty($tax_data['total'])){ |
| 283 |
$fee_line_tax_data[] = $tax_data['total']; |
| 284 |
}else{ |
| 285 |
$fee_line_tax_data = array(); |
| 286 |
} |
| 287 |
} |
| 288 |
//fee data |
| 289 |
self::$export_instance->data[$id]['fee_name'] = implode(',', $fee_name); |
| 290 |
self::$export_instance->data[$id]['fee_type'] = implode(',', $fee_type); |
| 291 |
//self::$export_instance->data[$id]['fee_line_subtotal'] = implode(',', $fee_line_subtotal); |
| 292 |
//self::$export_instance->data[$id]['fee_line_subtotal_tax'] = implode(',', $fee_line_subtotal_tax); |
| 293 |
self::$export_instance->data[$id]['fee_line_total'] = implode(',', $fee_line_total); |
| 294 |
self::$export_instance->data[$id]['fee_line_tax'] = implode(',', $fee_line_tax); |
| 295 |
self::$export_instance->data[$id]['fee_line_tax_data'] = implode(',',$fee_line_tax_data ); |
| 296 |
self::$export_instance->data[$id]['fee_tax_class'] = implode(',', $fee_tax_class); |
| 297 |
} |
| 298 |
//shipment data fetch |
| 299 |
$shipping_methods = $order->get_shipping_methods(); |
| 300 |
if(!empty($shipping_methods)){ |
| 301 |
foreach ($shipping_methods as $shipping_method) { |
| 302 |
$shipment_name[] = $shipping_method->get_method_title(); |
| 303 |
$shipment_method_id[] = $shipping_method->get_method_id(); |
| 304 |
$shipment_cost[] = $shipping_method->get_total(); |
| 305 |
$shipment_taxe_data = $shipping_method->get_taxes(); |
| 306 |
if(!empty($shipment_taxe_data['total'])){ |
| 307 |
$shipment_taxes[] = $shipment_taxe_data['total']; |
| 308 |
}else{ |
| 309 |
$shipment_taxes = array(); |
| 310 |
} |
| 311 |
} |
| 312 |
// shipment data |
| 313 |
self::$export_instance->data[$id]['shipment_name'] = implode(',', $shipment_name); |
| 314 |
self::$export_instance->data[$id]['shipment_method_id'] = implode(',', $shipment_method_id); |
| 315 |
self::$export_instance->data[$id]['shipment_cost'] = implode(',', $shipment_cost); |
| 316 |
self::$export_instance->data[$id]['shipment_taxes'] = implode(',', $shipment_taxes); |
| 317 |
} |
| 318 |
|
| 319 |
if(is_plugin_active('advanced-product-fields-for-woocommerce/advanced-product-fields-for-woocommerce.php') ) { |
| 320 |
$this->getPPOMData($id,$product_id); |
| 321 |
} |
| 322 |
if (is_plugin_active('woo-extra-product-options/woo-extra-product-options.php')) { |
| 323 |
$this->getEPOData($id,$product_id); |
| 324 |
} |
| 325 |
if (is_plugin_active('woo-custom-product-addons/start.php')) { |
| 326 |
$this->getWCPAData($id,$product_id); |
| 327 |
} |
| 328 |
if ( is_plugin_active( 'yith-woocommerce-order-tracking-premium/init.php' ) ) { |
| 329 |
self::$export_instance->data[$id]['ywot_tracking_code'] = $order->get_meta('ywot_tracking_code', true); |
| 330 |
self::$export_instance->data[$id]['ywot_tracking_postcode'] = $order->get_meta('ywot_tracking_postcode', true); |
| 331 |
self::$export_instance->data[$id]['ywot_carrier_id'] = $order->get_meta('ywot_carrier_id', true); |
| 332 |
self::$export_instance->data[$id]['ywot_pick_up_date'] = $order->get_meta('ywot_pick_up_date', true); |
| 333 |
self::$export_instance->data[$id]['ywot_estimated_delivery_date'] = $order->get_meta('ywot_estimated_delivery_date', true); |
| 334 |
self::$export_instance->data[$id]['ywot_picked_up'] = $order->get_meta('ywot_picked_up', true); |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
} |
| 339 |
|
| 340 |
/** |
| 341 |
* Code for PPOM export |
| 342 |
* @param $id |
| 343 |
* @param $product_id |
| 344 |
*/ |
| 345 |
public function getPPOMData($order_id, $product_ids) |
| 346 |
{ |
| 347 |
|
| 348 |
global $wpdb; |
| 349 |
$table_name = $wpdb->prefix . 'nm_personalized'; |
| 350 |
|
| 351 |
// Fetch all the PPOM field setups from the `wp_nm_personalized` table |
| 352 |
$field_setups = $wpdb->get_results( "SELECT * FROM $table_name" ); |
| 353 |
|
| 354 |
if ( !empty( $field_setups ) ) { |
| 355 |
|
| 356 |
foreach ( $field_setups as $setup ) { |
| 357 |
$meta_data = json_decode( $setup->the_meta, true ); // Unserialize the field meta data |
| 358 |
|
| 359 |
|
| 360 |
// Display the unserialized field data if available |
| 361 |
if ( is_array( $meta_data ) ) { |
| 362 |
|
| 363 |
foreach ( $meta_data as $key => $field ) { |
| 364 |
$pro_meta_fields[$field['title']] = $field['data_name']; |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
} |
| 369 |
} |
| 370 |
|
| 371 |
} |
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
// Get order items for the specified order ID |
| 376 |
$order_items = wc_get_order( $order_id )->get_items(); |
| 377 |
|
| 378 |
foreach ( $order_items as $item_id => $item ) { |
| 379 |
// Get the meta data for each order item |
| 380 |
$item_meta = wc_get_order_item_meta( $item_id, '', false ); |
| 381 |
|
| 382 |
foreach ( $item_meta as $meta_key => $meta_value ) { |
| 383 |
|
| 384 |
if ( array_key_exists($meta_key, $pro_meta_fields)) { // Change this condition based on your actual meta key format |
| 385 |
|
| 386 |
self::$export_instance->data[$order_id][$meta_key] = $meta_value[0]; // Store each field key-value pair |
| 387 |
|
| 388 |
} |
| 389 |
} |
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
} |
| 394 |
public function getEPOData($order_id, $product_ids) |
| 395 |
{ |
| 396 |
global $wpdb; |
| 397 |
|
| 398 |
// Fetch all EPO field setups from the `wp_woocommerce_order_itemmeta` table |
| 399 |
$table_name = $wpdb->prefix . 'woocommerce_order_itemmeta'; |
| 400 |
|
| 401 |
$epo_data = $wpdb->get_results( $wpdb->prepare( |
| 402 |
"SELECT * FROM $table_name WHERE order_item_id IN (SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d)", |
| 403 |
$order_id |
| 404 |
) ); |
| 405 |
|
| 406 |
$pro_meta_fields = []; |
| 407 |
|
| 408 |
if ( !empty( $epo_data ) ) { |
| 409 |
foreach ( $epo_data as $data ) { |
| 410 |
if ( is_serialized( $data->meta_value ) ) { |
| 411 |
$meta_data = unserialize( $data->meta_value ); |
| 412 |
} else { |
| 413 |
$meta_data = $data->meta_value; |
| 414 |
} |
| 415 |
|
| 416 |
if ( is_array( $meta_data ) ) { |
| 417 |
foreach ( $meta_data as $key => $field ) { |
| 418 |
if (isset($field['title']) && isset($field['data_name'])) { |
| 419 |
$pro_meta_fields[$field['title']] = $field['data_name']; |
| 420 |
} else { |
| 421 |
} |
| 422 |
} |
| 423 |
} else { |
| 424 |
$pro_meta_fields[$data->meta_key] = $meta_data; |
| 425 |
} |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
|
| 430 |
$order_items = wc_get_order($order_id)->get_items(); |
| 431 |
|
| 432 |
foreach ($order_items as $item_id => $item) { |
| 433 |
$item_meta = wc_get_order_item_meta($item_id, '', false); |
| 434 |
|
| 435 |
foreach ($item_meta as $meta_key => $meta_value) { |
| 436 |
if (array_key_exists($meta_key, $pro_meta_fields)) { |
| 437 |
if (is_array($meta_value) && isset($meta_value[0])) { |
| 438 |
self::$export_instance->data[$order_id][$meta_key] = $meta_value[0]; |
| 439 |
} else { |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
} |
| 444 |
} |
| 445 |
|
| 446 |
public function getWCPAData($order_id, $product_ids) |
| 447 |
{ |
| 448 |
global $wpdb; |
| 449 |
|
| 450 |
// Fetch all WCPA field setups from the `wp_woocommerce_order_itemmeta` table |
| 451 |
$table_name = $wpdb->prefix . 'woocommerce_order_itemmeta'; |
| 452 |
|
| 453 |
// Fetching metadata for the given order items |
| 454 |
$wcpa_data = $wpdb->get_results($wpdb->prepare( |
| 455 |
"SELECT * FROM $table_name WHERE order_item_id IN (SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d)", |
| 456 |
$order_id |
| 457 |
)); |
| 458 |
|
| 459 |
$pro_meta_fields = []; |
| 460 |
|
| 461 |
if (!empty($wcpa_data)) { |
| 462 |
foreach ($wcpa_data as $data) { |
| 463 |
// Check if the meta_value is serialized, then unserialize it |
| 464 |
if (is_serialized($data->meta_value)) { |
| 465 |
$meta_data = unserialize($data->meta_value); |
| 466 |
} else { |
| 467 |
$meta_data = $data->meta_value; |
| 468 |
} |
| 469 |
|
| 470 |
// Check if the meta_data is an array |
| 471 |
if (is_array($meta_data)) { |
| 472 |
foreach ($meta_data as $key => $field) { |
| 473 |
if (isset($field['title']) && isset($field['data_name'])) { |
| 474 |
// Adjusting keys to match export requirements |
| 475 |
$pro_meta_fields[$field['label']] = $field['value']; // Use label and value instead of title and data_name |
| 476 |
} |
| 477 |
} |
| 478 |
} else { |
| 479 |
// If it's not an array, directly assign the meta_key to the fields |
| 480 |
$pro_meta_fields[$data->meta_key] = $meta_data; |
| 481 |
} |
| 482 |
} |
| 483 |
} |
| 484 |
|
| 485 |
// Fetching all order items for the given order_id |
| 486 |
$order_items = wc_get_order($order_id)->get_items(); |
| 487 |
|
| 488 |
foreach ($order_items as $item_id => $item) { |
| 489 |
// Get item metadata for each order item |
| 490 |
$item_meta = wc_get_order_item_meta($item_id, '', false); |
| 491 |
|
| 492 |
// Loop through the item meta and check if the meta_key exists in the pro_meta_fields |
| 493 |
foreach ($item_meta as $meta_key => $meta_value) { |
| 494 |
if (array_key_exists($meta_key, $pro_meta_fields)) { |
| 495 |
// Adjusting keys to match export requirements |
| 496 |
if (is_array($meta_value) && isset($meta_value[0])) { |
| 497 |
self::$export_instance->data[$order_id][str_replace(' ', '-', strtolower($meta_key))] = $meta_value[0]; // Convert key format |
| 498 |
} |
| 499 |
} |
| 500 |
} |
| 501 |
} |
| 502 |
} |
| 503 |
|
| 504 |
/** |
| 505 |
* Code for Woocommerce Refund export |
| 506 |
* @param $id |
| 507 |
* @param $type |
| 508 |
* @param $optionalType |
| 509 |
*/ |
| 510 |
public function getWooComCustomerUser($id, $type, $optionalType) |
| 511 |
{ |
| 512 |
global $wpdb; |
| 513 |
$parent = WooCommerceExport::$export_instance->data[$id]['post_parent']; |
| 514 |
$query = $wpdb->prepare("SELECT post_id,meta_key,meta_value FROM {$wpdb->prefix}postmeta where post_id = %d", $parent); |
| 515 |
$result = $wpdb->get_results($query); |
| 516 |
if(!empty($result)){ |
| 517 |
foreach ($result as $key => $value) { |
| 518 |
if($value->meta_key == '_customer_user'){ |
| 519 |
$cus_user = $value->meta_value; |
| 520 |
} |
| 521 |
} |
| 522 |
} |
| 523 |
WooCommerceExport::$export_instance->data[$id]['customer_user'] = $cus_user; |
| 524 |
} |
| 525 |
|
| 526 |
/** |
| 527 |
* Export woocommerce product and variation |
| 528 |
* @param $id |
| 529 |
* @param $type |
| 530 |
* @param $optionalType |
| 531 |
*/ |
| 532 |
public function getVariationData($id, $type, $optionalType) |
| 533 |
{ |
| 534 |
$variations_data = wc_get_product($id); |
| 535 |
$variation_datas = $variations_data->get_data(); |
| 536 |
$variations[] = wc_get_product($id); |
| 537 |
foreach ($variations as $attr_key => $variation) { |
| 538 |
$parent_id = $variation->get_parent_id(); |
| 539 |
$parent_product = wc_get_product($parent_id); |
| 540 |
$parent_sku = $parent_product->get_sku(); |
| 541 |
$variation_sku = $variation->get_sku(); |
| 542 |
$variation_id = $variation->get_id(); |
| 543 |
$featured_image_id = $variation->get_image_id(); |
| 544 |
$featured_image_url = wp_get_attachment_image_url($featured_image_id, 'full'); |
| 545 |
$product_attributes = $parent_product->get_attributes(); |
| 546 |
$attribute_name = $att_values = $is_visible = $is_variation = $position = $is_taxonomy = []; |
| 547 |
|
| 548 |
foreach ($product_attributes as $attribute_key => $attribute) { |
| 549 |
$attribute_name[] = str_replace('pa_', '', $attribute['name']); |
| 550 |
$taxonomy_name = $attribute['taxonomy']; |
| 551 |
$attribute_options = $attribute['options']; |
| 552 |
$term_names = []; |
| 553 |
foreach ($attribute_options as $term_key => $term_id) { |
| 554 |
$term = get_term_by('id', $term_id, $taxonomy_name); |
| 555 |
if (!empty($term->name)) { |
| 556 |
$term_names[] = $term->name; |
| 557 |
} |
| 558 |
} |
| 559 |
if (!empty($term_names)) { |
| 560 |
$att_values[] = implode('|', $term_names); // Combine term names with | |
| 561 |
} |
| 562 |
$is_visible[] = $attribute['is_visible']; |
| 563 |
$is_variation[] = $attribute['is_variation']; |
| 564 |
$position[] = $attribute['position']; |
| 565 |
} |
| 566 |
$attachment_meta = wp_get_attachment_metadata($featured_image_id); |
| 567 |
$product_caption = isset($attachment_meta['image_meta']['caption']) ? $attachment_meta['image_meta']['caption'] : ''; |
| 568 |
$product_alt_text = get_post_meta($featured_image_id, '_wp_attachment_image_alt', true); |
| 569 |
$product_description = get_post_field('post_content', $featured_image_id); |
| 570 |
|
| 571 |
$product_title = $parent_product->get_title(); |
| 572 |
$is_featured = get_post_meta($parent_product->get_id(), 'featured', true) ? '1' : '0'; |
| 573 |
$downloadable = $variation->is_downloadable() ? 'yes' : 'no'; |
| 574 |
if ($variation->is_downloadable()) { |
| 575 |
$download_limit = $variation->get_download_limit(); |
| 576 |
$download_expiry = $variation->get_download_expiry(); |
| 577 |
$downloadable_files = []; |
| 578 |
$download_type = []; |
| 579 |
$downloads = $variation->get_downloads(); |
| 580 |
foreach ($downloads as $download) { |
| 581 |
$file_string = $download['name'].','.$download['file']; |
| 582 |
$downloadable_files[] = $file_string; |
| 583 |
} |
| 584 |
$download_file_str = implode('|', $downloadable_files); |
| 585 |
WooCommerceExport::$export_instance->data[$id]['downloadable_files'] = $download_file_str ?? ''; |
| 586 |
WooCommerceExport::$export_instance->data[$id]['download_limit'] = $download_limit ?? ''; |
| 587 |
WooCommerceExport::$export_instance->data[$id]['download_expiry'] = $download_expiry ?? ''; |
| 588 |
} |
| 589 |
$price = $variation->get_price(); |
| 590 |
$sale_price_dates_from = $variation->get_date_on_sale_from(); |
| 591 |
$sale_price_dates_to = $variation->get_date_on_sale_to(); |
| 592 |
$regular_price = $variation->get_regular_price(); |
| 593 |
$sale_price = $variation->get_sale_price(); |
| 594 |
$purchase_note = $variation->get_purchase_note(); |
| 595 |
$default_attributes = $variation->get_default_attributes(); |
| 596 |
$attribute_default = []; |
| 597 |
foreach ($default_attributes as $def_attribute_key => $def_attribute_value) { |
| 598 |
$attribute_default[] = str_replace('pa_', '', $def_attribute_key) . '|' . $def_attribute_value; |
| 599 |
} |
| 600 |
$custom_attributes = $variation->get_attributes(); |
| 601 |
$attribute_names = []; |
| 602 |
foreach ($custom_attributes as $cus_attribute_key => $cus_attribute_value) { |
| 603 |
if(strpos($cus_attribute_value,'-')!== false){ |
| 604 |
$cus_attribute_value = str_replace('-',' ',$cus_attribute_value); |
| 605 |
} |
| 606 |
$attribute_names[] = str_replace('pa_', '', $cus_attribute_key) . '|' . $cus_attribute_value; |
| 607 |
} |
| 608 |
$tax_status = $variation->get_tax_status(); |
| 609 |
$tax_status_mapping = array('taxable' => 1 , 'shipping' => 2, 'none' => 3); |
| 610 |
$is_virtual = $variation->is_virtual() ? 'yes' : 'no'; |
| 611 |
if(!$variation->is_virtual()){ |
| 612 |
$weight = $variation->get_weight(); |
| 613 |
$length = $variation->get_length(); |
| 614 |
$width = $variation->get_width(); |
| 615 |
$height = $variation->get_height(); |
| 616 |
} |
| 617 |
$manages_stock = $variation->managing_stock() ? 'yes' : 'no'; |
| 618 |
$stock_status = $variation->get_stock_status(); |
| 619 |
$sold_individually = $variation->get_sold_individually(); |
| 620 |
if($variation->managing_stock()){ |
| 621 |
$stock_qty = $variation->get_stock_quantity(); |
| 622 |
$low_stock_amount = $variation->get_low_stock_amount(); |
| 623 |
$backorders = $variation->get_backorders(); |
| 624 |
switch ($backorders) { |
| 625 |
case 'no': |
| 626 |
$backorders_no= '1'; |
| 627 |
break; |
| 628 |
|
| 629 |
case 'notify': |
| 630 |
$backorders_no= '2'; |
| 631 |
break; |
| 632 |
|
| 633 |
case 'yes': |
| 634 |
$backorders_no = '3'; |
| 635 |
break; |
| 636 |
|
| 637 |
default: |
| 638 |
$backorders_no = ''; |
| 639 |
break; |
| 640 |
} |
| 641 |
} |
| 642 |
$var_description = $variation->get_description(); |
| 643 |
$var_class_id = $variation->get_shipping_class_id(); |
| 644 |
$shipping_class_term = get_term($var_class_id, 'product_shipping_class'); |
| 645 |
} |
| 646 |
WooCommerceExport::$export_instance->data[$id]['PARENTSKU'] = $parent_sku ; |
| 647 |
WooCommerceExport::$export_instance->data[$id]['VARIATIONSKU'] = $variation_sku; |
| 648 |
WooCommerceExport::$export_instance->data[$id]['VARIATIONID'] = $variation_id; |
| 649 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_name'] = implode('|',$attribute_name); |
| 650 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_value'] = implode(',', $att_values); |
| 651 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_visible'] = implode('|', $is_visible); |
| 652 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_variation'] = implode('|', $is_variation); |
| 653 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_position'] = implode('|', $position); |
| 654 |
|
| 655 |
WooCommerceExport::$export_instance->data[$id]['product_caption'] = $product_caption ?? ''; |
| 656 |
WooCommerceExport::$export_instance->data[$id]['product_alt_text'] = $product_alt_text ?? ''; |
| 657 |
WooCommerceExport::$export_instance->data[$id]['product_description'] = $product_description ?? ''; |
| 658 |
|
| 659 |
WooCommerceExport::$export_instance->data[$id]['product_title'] = $product_title ?? ''; |
| 660 |
WooCommerceExport::$export_instance->data[$id]['featured'] = $is_featured ?? ''; |
| 661 |
|
| 662 |
WooCommerceExport::$export_instance->data[$id]['price'] = $price ?? ''; |
| 663 |
WooCommerceExport::$export_instance->data[$id]['sale_price_dates_from'] = $sale_price_dates_from ?? ''; |
| 664 |
WooCommerceExport::$export_instance->data[$id]['sale_price_dates_to'] = $sale_price_dates_to ?? ''; |
| 665 |
WooCommerceExport::$export_instance->data[$id]['regular_price'] = $regular_price ?? ''; |
| 666 |
WooCommerceExport::$export_instance->data[$id]['sale_price'] = $sale_price ?? ''; |
| 667 |
WooCommerceExport::$export_instance->data[$id]['purchase_note'] = $purchase_note ?? ''; |
| 668 |
|
| 669 |
WooCommerceExport::$export_instance->data[$id]['default_attributes'] = implode(',',$attribute_default) ?? ''; |
| 670 |
WooCommerceExport::$export_instance->data[$id]['custom_attributes'] = implode(',',$attribute_names) ?? ''; |
| 671 |
WooCommerceExport::$export_instance->data[$id]['_downloadable'] = $downloadable ?? ''; |
| 672 |
|
| 673 |
WooCommerceExport::$export_instance->data[$id]['tax_class'] = $variation_datas['tax_class'] ?? ''; |
| 674 |
WooCommerceExport::$export_instance->data[$id]['tax_status'] = array_key_exists($tax_status,$tax_status_mapping) ? $tax_status_mapping[$tax_status] : '' ; |
| 675 |
|
| 676 |
WooCommerceExport::$export_instance->data[$id]['weight'] = $weight ?? ''; |
| 677 |
WooCommerceExport::$export_instance->data[$id]['length'] = $length ?? ''; |
| 678 |
WooCommerceExport::$export_instance->data[$id]['width'] = $width ?? ''; |
| 679 |
WooCommerceExport::$export_instance->data[$id]['height'] = $height ?? ''; |
| 680 |
|
| 681 |
WooCommerceExport::$export_instance->data[$id]['virtual'] = $is_virtual ?? ''; |
| 682 |
|
| 683 |
WooCommerceExport::$export_instance->data[$id]['manage_stock'] = $manages_stock ?? ''; |
| 684 |
WooCommerceExport::$export_instance->data[$id]['_stock'] = $stock_qty ?? ''; |
| 685 |
WooCommerceExport::$export_instance->data[$id]['_stock_status'] = $stock_status ?? ''; |
| 686 |
WooCommerceExport::$export_instance->data[$id]['_low_stock_threshold'] = $low_stock_amount ?? ''; |
| 687 |
WooCommerceExport::$export_instance->data[$id]['_stock_qty'] = $stock_qty ?? ''; |
| 688 |
WooCommerceExport::$export_instance->data[$id]['backorders'] = $backorders_no; |
| 689 |
WooCommerceExport::$export_instance->data[$id]['sold_individually'] = ($sold_individually > 0) ? 'yes' : 'no'; |
| 690 |
WooCommerceExport::$export_instance->data[$id]['_thumbnail_id'] = $featured_image_url ?? ''; |
| 691 |
|
| 692 |
WooCommerceExport::$export_instance->data[$id]['variation_description'] = $var_description ?? ''; |
| 693 |
WooCommerceExport::$export_instance->data[$id]['variation_shipping_class'] = $shipping_class_term ? $shipping_class_term->name : ''; |
| 694 |
} |
| 695 |
// public function getProductData($id, $type, $optionalType) |
| 696 |
// { |
| 697 |
// $product = wc_get_product($id); |
| 698 |
// $product_datas = $product->get_data(); |
| 699 |
// $product_sku = $product->get_sku(); |
| 700 |
// WooCommerceExport::$export_instance->data[$id]['PRODUCTSKU'] = $product_sku; |
| 701 |
// $product_attributes = $product->get_attributes(); |
| 702 |
// if (!empty($product_attributes)) { |
| 703 |
// foreach ($product_attributes as $attribute_key => $attribute) { |
| 704 |
// $attribute_name[] = str_replace('pa_', '', $attribute['name']); |
| 705 |
// $taxonomy_name = $attribute['taxonomy']; |
| 706 |
// $attribute_options = $attribute['options']; |
| 707 |
// $term_names = $att_values = []; |
| 708 |
// foreach ($attribute_options as $term_key => $term_id) { |
| 709 |
// $term = get_term_by('id', $term_id, $taxonomy_name); |
| 710 |
// if (!empty($term->name)) { |
| 711 |
// $term_names[] = $term->name; |
| 712 |
// } |
| 713 |
// } |
| 714 |
// if (!empty($term_names)) { |
| 715 |
// $att_values[] = implode('|', $term_names); |
| 716 |
// } |
| 717 |
// $is_visible[] = $attribute['is_visible']; |
| 718 |
// $is_variation[] = $attribute['is_variation']; |
| 719 |
// $position[] = $attribute['position']; |
| 720 |
// $is_taxonomy[] = $attribute['is_taxonomy']; |
| 721 |
// } |
| 722 |
// WooCommerceExport::$export_instance->data[$id]['product_attribute_name'] = implode('|', $attribute_name); |
| 723 |
// WooCommerceExport::$export_instance->data[$id]['product_attribute_value'] = implode(',', $att_values); |
| 724 |
// WooCommerceExport::$export_instance->data[$id]['product_attribute_visible'] = implode('|', $is_visible); |
| 725 |
// WooCommerceExport::$export_instance->data[$id]['product_attribute_variation'] = implode('|', $is_variation); |
| 726 |
// WooCommerceExport::$export_instance->data[$id]['product_attribute_position'] = implode('|', $position); |
| 727 |
// WooCommerceExport::$export_instance->data[$id]['product_attribute_taxonomy'] = implode('|', $is_taxonomy); |
| 728 |
// } |
| 729 |
|
| 730 |
|
| 731 |
// $get_catalog_visibility = $product->get_catalog_visibility(); |
| 732 |
// $visibility_mapping = array('visible' => '1','catalog' => '2','search' => '3','hidden' => '4'); |
| 733 |
// WooCommerceExport::$export_instance->data[$id]['visibility'] = array_key_exists($get_catalog_visibility,$visibility_mapping) ? $visibility_mapping[$get_catalog_visibility] : ''; |
| 734 |
|
| 735 |
// $tax_status = $product->get_tax_status(); |
| 736 |
// $tax_status_mapping = array('taxable' => 1 , 'shipping' => 2, 'none' => 3); |
| 737 |
// WooCommerceExport::$export_instance->data[$id]['tax_status'] = array_key_exists($tax_status,$tax_status_mapping) ? $tax_status_mapping[$tax_status] : '' ; |
| 738 |
|
| 739 |
// $product_type = $product->get_type(); |
| 740 |
// $product_type_mapping = array('simple' => 1 , 'grouped' => 2, 'external' => 3, 'variable' => 4 , 'subscription' => 5 , 'variable-subscription' => 6 ,'bundle' => 7); |
| 741 |
// WooCommerceExport::$export_instance->data[$id]['product_type'] = array_key_exists($product_type,$product_type_mapping) ? $product_type_mapping[$product_type] : '' ; |
| 742 |
|
| 743 |
// if (has_term('featured', 'product_visibility', $id)) { |
| 744 |
// WooCommerceExport::$export_instance->data[$id]['featured_product'] = '1'; |
| 745 |
// } |
| 746 |
// WooCommerceExport::$export_instance->data[$id]['tax_class'] = $product_datas['tax_class'] ?? ''; |
| 747 |
// if (method_exists($product, 'get_file_paths')) { |
| 748 |
// $file_paths = $product->get_file_paths(); |
| 749 |
// WooCommerceExport::$export_instance->data[$id]['_file_paths'] = isset($file_paths) ? $file_paths : ''; |
| 750 |
// } else { |
| 751 |
// WooCommerceExport::$export_instance->data[$id]['_file_paths'] = ''; |
| 752 |
// } |
| 753 |
// $edit_last = get_post_meta($id, '_edit_last', true); |
| 754 |
// WooCommerceExport::$export_instance->data[$id]['_edit_last'] = $edit_last ?? ''; |
| 755 |
// $edit_lock = get_post_meta($id, '_edit_lock', true); |
| 756 |
// WooCommerceExport::$export_instance->data[$id]['_edit_lock'] = $edit_lock ?? ''; |
| 757 |
// $thumbnail_id = get_post_thumbnail_id($product->get_id()); |
| 758 |
// $attachment_url = wp_get_attachment_url($thumbnail_id); |
| 759 |
// WooCommerceExport::$export_instance->data[$id]['_thumbnail_id'] = $attachment_url ?? ''; |
| 760 |
// WooCommerceExport::$export_instance->data[$id]['manage_stock'] = $product->get_manage_stock() ? '1' : ''; |
| 761 |
// $stock_quantity = $product->get_stock_quantity(); |
| 762 |
// $stock_status = $product->get_stock_status(); |
| 763 |
// $low_stock_threshold = $product->get_low_stock_amount(); |
| 764 |
// $total_sales = $product->get_total_sales(); |
| 765 |
// WooCommerceExport::$export_instance->data[$id]['_stock'] = $stock_quantity ?? ''; |
| 766 |
// WooCommerceExport::$export_instance->data[$id]['_stock_status'] = $stock_status ?? ''; |
| 767 |
// WooCommerceExport::$export_instance->data[$id]['_low_stock_threshold'] = $low_stock_threshold ?? ''; |
| 768 |
// WooCommerceExport::$export_instance->data[$id]['_stock_qty'] = $stock_quantity ?? ''; |
| 769 |
// WooCommerceExport::$export_instance->data[$id]['_total_sales'] = $total_sales ?? ''; |
| 770 |
// $downloadable = $product->is_downloadable() ? 'yes' : 'no'; |
| 771 |
// $virtual = $product->is_virtual() ? 'yes' : 'no'; |
| 772 |
// $regular_price = $product->get_regular_price(); |
| 773 |
// $sale_price = $product->get_sale_price(); |
| 774 |
// $purchase_note = $product->get_purchase_note(); |
| 775 |
|
| 776 |
// WooCommerceExport::$export_instance->data[$id]['_downloadable'] = $downloadable ?? ''; |
| 777 |
// WooCommerceExport::$export_instance->data[$id]['_virtual'] = $virtual ?? ''; |
| 778 |
// WooCommerceExport::$export_instance->data[$id]['_regular_price'] = $regular_price ?? ''; |
| 779 |
// WooCommerceExport::$export_instance->data[$id]['_sale_price'] = $sale_price ?? ''; |
| 780 |
// WooCommerceExport::$export_instance->data[$id]['_purchase_note'] = $purchase_note ?? ''; |
| 781 |
|
| 782 |
// $weight = $product->get_weight(); |
| 783 |
// $length = $product->get_length(); |
| 784 |
// $width = $product->get_width(); |
| 785 |
// $height = $product->get_height(); |
| 786 |
// $upsell_ids = $product->get_upsell_ids(); |
| 787 |
// $upsell_product_names = []; |
| 788 |
// foreach ($upsell_ids as $up_id) { |
| 789 |
// $upsell_product = wc_get_product($up_id); |
| 790 |
// $upsell_product_names[] = $upsell_product ? $upsell_product->get_name() : ''; |
| 791 |
// } |
| 792 |
// $cross_sell_ids = $product->get_cross_sell_ids(); |
| 793 |
// $cross_sell_product_names = []; |
| 794 |
// foreach ($cross_sell_ids as $cross_id) { |
| 795 |
// $cross_sell_product = wc_get_product($cross_id); |
| 796 |
// $cross_sell_product_names[] = $cross_sell_product ? $cross_sell_product->get_name() : ''; |
| 797 |
// } |
| 798 |
// WooCommerceExport::$export_instance->data[$id]['weight'] = $weight ?? ''; |
| 799 |
// WooCommerceExport::$export_instance->data[$id]['length'] = $length ?? ''; |
| 800 |
// WooCommerceExport::$export_instance->data[$id]['width'] = $width ?? ''; |
| 801 |
// WooCommerceExport::$export_instance->data[$id]['height'] = $height ?? ''; |
| 802 |
// WooCommerceExport::$export_instance->data[$id]['upsell_ids'] = implode(',', $upsell_product_names) ?? ''; |
| 803 |
// WooCommerceExport::$export_instance->data[$id]['crosssell_ids'] = implode(',', $cross_sell_product_names) ?? ''; |
| 804 |
|
| 805 |
// $grouping_product_ids = []; // Initialize an array to store child product IDs |
| 806 |
// if ($product->is_type('grouped')) { |
| 807 |
// $children = $product->get_children(); |
| 808 |
// foreach ($children as $child_id) { |
| 809 |
// $child = wc_get_product($child_id); |
| 810 |
// if (!empty($child)) { |
| 811 |
// $grouping_product_ids[] = $child_id; |
| 812 |
// } |
| 813 |
// } |
| 814 |
// } |
| 815 |
// $grouping_product_ids_string = implode(',', $grouping_product_ids); |
| 816 |
// WooCommerceExport::$export_instance->data[$id]['grouping_product'] = $grouping_product_ids_string; |
| 817 |
|
| 818 |
// $sale_price_dates_from = $product->get_date_on_sale_from(); |
| 819 |
// $sale_price_dates_to = $product->get_date_on_sale_to(); |
| 820 |
// $sold_individually = $product->get_sold_individually(); |
| 821 |
// $backorders = $product->get_backorders(); |
| 822 |
// switch ($backorders) { |
| 823 |
// case 'no': |
| 824 |
// $backorders_no= '1'; |
| 825 |
// break; |
| 826 |
|
| 827 |
// case 'notify': |
| 828 |
// $backorders_no= '2'; |
| 829 |
// break; |
| 830 |
|
| 831 |
// case 'yes': |
| 832 |
// $backorders_no = '3'; |
| 833 |
// break; |
| 834 |
|
| 835 |
// default: |
| 836 |
// $backorders_no = ''; |
| 837 |
// break; |
| 838 |
// } |
| 839 |
// // WooCommerceExport::$export_instance->data[$id]['grouping_product'] = implode(',',$grouping_products); |
| 840 |
// WooCommerceExport::$export_instance->data[$id]['sale_price_dates_from'] = $sale_price_dates_from ?? ''; |
| 841 |
// WooCommerceExport::$export_instance->data[$id]['sale_price_dates_to'] = $sale_price_dates_to ?? ''; |
| 842 |
// WooCommerceExport::$export_instance->data[$id]['sold_individually'] = ($sold_individually > 0) ? 'yes' : 'no'; |
| 843 |
// WooCommerceExport::$export_instance->data[$id]['backorders'] = $backorders_no; |
| 844 |
// $product_url = ($product->is_type('external')) ? $product->get_product_url() : ''; |
| 845 |
// $button_text = ($product->is_type('external')) ? $product->single_add_to_cart_text() : ''; |
| 846 |
// $featured =get_post_meta($product->get_id(), 'featured', true) ? '1' : '0'; |
| 847 |
// WooCommerceExport::$export_instance->data[$id]['product_url'] = $product_url; |
| 848 |
// WooCommerceExport::$export_instance->data[$id]['button_text'] = $button_text; |
| 849 |
// WooCommerceExport::$export_instance->data[$id]['featured'] = $featured; |
| 850 |
// $downloadable_files = []; |
| 851 |
// $download_type = []; |
| 852 |
// if(($product->is_type('variable'))){ |
| 853 |
// $download_limits = []; |
| 854 |
// $download_expiries = []; |
| 855 |
// $variations = $product->get_children(); |
| 856 |
// foreach ($variations as $variation_id) { |
| 857 |
// $variation = wc_get_product($variation_id); |
| 858 |
// // Check if the variation is downloadable |
| 859 |
// if ($variation->is_downloadable()) { |
| 860 |
// $downloads = $variation->get_downloads(); |
| 861 |
// foreach ($downloads as $download) { |
| 862 |
// $file_url = $download->get_file(); // Get the file URL |
| 863 |
// $file_name = $download->get_name(); // Get the file name |
| 864 |
// $file_string = $file_name.','.$file_url; |
| 865 |
// $downloadable_files[] = $file_string; |
| 866 |
// if (strpos($file_url, 'http') === 0) { |
| 867 |
// $download_type[] = 'external'; // If URL starts with http, it's an external URL |
| 868 |
// } else { |
| 869 |
// $download_type[] = 'file'; // Otherwise, it's a file URL |
| 870 |
// } |
| 871 |
|
| 872 |
// } |
| 873 |
// $download_limit = $variation->get_download_limit(); // Default is -1 for unlimited |
| 874 |
// $download_expiry = $variation->get_download_expiry(); // Default is -1 for no expiry |
| 875 |
// // Store the values |
| 876 |
// $download_limits[] = $download_limit; |
| 877 |
// $download_expiries[] = $download_expiry; |
| 878 |
|
| 879 |
// } |
| 880 |
// $download_limit = !empty($download_limit) ? implode('|', $download_limits) : ''; |
| 881 |
// $download_expiry = !empty($download_expiry) ? implode('|', $download_expiries) : ''; |
| 882 |
// $download_type_str = !empty($download_type) ? implode('|', $download_type) : ''; |
| 883 |
// $download_file_str = !empty($downloadable_files) ? implode('|', $downloadable_files) : ''; |
| 884 |
// } |
| 885 |
// }else{ |
| 886 |
// $downloads = $product->get_downloads(); |
| 887 |
// foreach ($downloads as $download) { |
| 888 |
// $file_string = $download['name'].','.$download['file']; |
| 889 |
// $downloadable_files[] = $file_string; |
| 890 |
// if (strpos($download['file'], 'http') === 0) { |
| 891 |
// $download_type[] = 'external'; // If URL starts with http, it's an external URL |
| 892 |
// } else { |
| 893 |
// $download_type[] = 'file'; // Otherwise, it's a file URL |
| 894 |
// } |
| 895 |
// } |
| 896 |
// $download_type_str = !empty($download_type) ? implode('|', $download_type) : ''; |
| 897 |
// $download_file_str = !empty($downloadable_files) ? implode('|', $downloadable_files) : ''; |
| 898 |
|
| 899 |
// $download_limit = $product->get_download_limit(); |
| 900 |
// $download_expiry = $product->get_download_expiry(); |
| 901 |
// } |
| 902 |
|
| 903 |
// WooCommerceExport::$export_instance->data[$id]['downloadable_files'] = $download_file_str; |
| 904 |
// WooCommerceExport::$export_instance->data[$id]['download_limit'] = ($download_limit > -1) ? $download_limit : ''; |
| 905 |
// WooCommerceExport::$export_instance->data[$id]['download_expiry'] = ($download_expiry > -1) ? $download_expiry : ''; |
| 906 |
// WooCommerceExport::$export_instance->data[$id]['download_type'] = $download_type_str; |
| 907 |
|
| 908 |
// $subscription_period = get_post_meta($id, '_subscription_period', true); |
| 909 |
// $subscription_period_interval = get_post_meta($id, '_subscription_period_interval', true); |
| 910 |
// $subscription_length = get_post_meta($id, '_subscription_length', true); |
| 911 |
// $subscription_trial_period = get_post_meta($id, '_subscription_trial_period', true); |
| 912 |
// $subscription_trial_length = get_post_meta($id, '_subscription_trial_length', true); |
| 913 |
// $subscription_price = get_post_meta($id, '_subscription_price', true); |
| 914 |
// $subscription_sign_up_fee = get_post_meta($id, '_subscription_sign_up_fee', true); |
| 915 |
|
| 916 |
// WooCommerceExport::$export_instance->data[$id]['_subscription_period'] = $subscription_period ?? ''; |
| 917 |
// WooCommerceExport::$export_instance->data[$id]['_subscription_period_interval'] = $subscription_period_interval ?? ''; |
| 918 |
// WooCommerceExport::$export_instance->data[$id]['_subscription_length'] = $subscription_length ?? ''; |
| 919 |
// WooCommerceExport::$export_instance->data[$id]['_subscription_trial_period'] = $subscription_trial_period ?? ''; |
| 920 |
// WooCommerceExport::$export_instance->data[$id]['_subscription_trial_length'] = $subscription_trial_length ?? ''; |
| 921 |
// WooCommerceExport::$export_instance->data[$id]['_subscription_price'] = $subscription_price ?? ''; |
| 922 |
// WooCommerceExport::$export_instance->data[$id]['_subscription_sign_up_fee'] = $subscription_sign_up_fee ?? ''; |
| 923 |
// // Retrieve barcode details |
| 924 |
// if(is_plugin_active('yith-woocommerce-barcodes-premium/init.php' )){ |
| 925 |
// $barcode_protocol = get_post_meta($id, '_ywbc_barcode_protocol', true); |
| 926 |
// $barcode_value = get_post_meta($id, '_ywbc_barcode_value', true); |
| 927 |
// $barcode_display_value = get_post_meta($id, '_ywbc_barcode_display_value', true); |
| 928 |
// WooCommerceExport::$export_instance->data[$id]['_ywbc_barcode_display_value'] = $barcode_display_value ?? ''; |
| 929 |
// WooCommerceExport::$export_instance->data[$id]['_ywbc_barcode_value'] = $barcode_value ?? ''; |
| 930 |
// WooCommerceExport::$export_instance->data[$id]['_ywbc_barcode_protocol'] = $barcode_protocol ?? ''; |
| 931 |
// } |
| 932 |
|
| 933 |
|
| 934 |
// //woocommerce-product-bundles plugin |
| 935 |
// //woocommerce-product-bundles plugin |
| 936 |
// if (is_plugin_active('woocommerce-product-bundles/woocommerce-product-bundles.php')) { |
| 937 |
// // Get the bundle product |
| 938 |
// $bundle_product = wc_get_product($id); |
| 939 |
|
| 940 |
// if ($bundle_product && $bundle_product->is_type('bundle')) { |
| 941 |
// // Initialize default values |
| 942 |
// $bundle_items = array(); |
| 943 |
// $optional_values = array(); |
| 944 |
// $quantity_min = array(); |
| 945 |
// $quantity_max = array(); |
| 946 |
// $price_values = array(); |
| 947 |
// $discount_values = array(); |
| 948 |
// $product_values = array(); |
| 949 |
// $cart_values = array(); |
| 950 |
// $order_values = array(); |
| 951 |
// $product_price_values = array(); |
| 952 |
// $cart_price_values = array(); |
| 953 |
// $order_price_values = array(); |
| 954 |
// $thumb_values = array(); |
| 955 |
// $override_values = array(); |
| 956 |
// $description_values = array(); |
| 957 |
// $override_title_values = array(); |
| 958 |
// $override_description_values = array(); |
| 959 |
|
| 960 |
// // Get bundle settings |
| 961 |
// $min_bundle_size = $bundle_product->get_min_bundle_size(); |
| 962 |
// $max_bundle_size = $bundle_product->get_max_bundle_size(); |
| 963 |
// $edit_in_cart = $bundle_product->get_editable_in_cart() ? 'Yes' : 'No'; |
| 964 |
// $layout = $bundle_product->get_layout(); // Assuming this method exists |
| 965 |
// $get_mode = $bundle_product->get_group_mode(); |
| 966 |
// if($get_mode == 'noindent'){ |
| 967 |
// $item_grouping = 'flat'; |
| 968 |
// }else if($get_mode == 'parent'){ |
| 969 |
// $item_grouping = 'grouped'; |
| 970 |
// }else{ |
| 971 |
// $item_grouping = ''; |
| 972 |
// } |
| 973 |
// foreach ($bundle_product->get_bundled_items() as $bundled_item) { |
| 974 |
// // Get bundled item product |
| 975 |
// $bundled_product = $bundled_item->get_product(); |
| 976 |
// $bundle_items[] = $bundled_product->get_name(); |
| 977 |
|
| 978 |
// // Retrieve settings for each bundled item |
| 979 |
// $optional_values[] = method_exists($bundled_item, 'is_optional') && $bundled_item->is_optional() ? 'Yes' : 'No'; |
| 980 |
// $quantity_min[] = method_exists($bundled_item, 'get_min_quantity') ? $bundled_item->get_min_quantity() : ''; |
| 981 |
// $quantity_max[] = method_exists($bundled_item, 'get_max_quantity') ? $bundled_item->get_max_quantity() : ''; |
| 982 |
// $price_values[] = method_exists($bundled_item, 'is_priced_individually') && $bundled_item->is_priced_individually() ? 'Yes' : 'No'; |
| 983 |
// $discount_values[] = method_exists($bundled_item, 'get_discount') ? $bundled_item->get_discount() : ''; |
| 984 |
// $product_values[] = method_exists($bundled_item, 'get_single_product_visibility') && $bundled_item->get_single_product_visibility() ? 'Yes' : 'No'; |
| 985 |
// $cart_values[] = method_exists($bundled_item, 'get_cart_visibility') && $bundled_item->get_cart_visibility() ? 'Yes' : 'No'; |
| 986 |
// $order_values[] = method_exists($bundled_item, 'get_order_visibility') && $bundled_item->get_order_visibility() ? 'Yes' : 'No'; |
| 987 |
// $product_price_values[] = method_exists($bundled_item, 'get_single_product_price_visibility') && $bundled_item->get_single_product_price_visibility() ? 'Yes' : 'No'; |
| 988 |
// $cart_price_values[] = method_exists($bundled_item, 'get_cart_price_visibility') && $bundled_item->get_cart_price_visibility() ? 'Yes' : 'No'; |
| 989 |
// $order_price_values[] = method_exists($bundled_item, 'get_order_price_visibility') && $bundled_item->get_order_price_visibility() ? 'Yes' : 'No'; |
| 990 |
// $thumb_values[] = method_exists($bundled_item, 'get_hide_thumbnail') && $bundled_item->get_hide_thumbnail() ? 'Yes' : 'No'; |
| 991 |
// $override_values[] = method_exists($bundled_item, 'get_override_title') && $bundled_item->get_override_title() ? 'Yes' : 'No'; |
| 992 |
// $description_values[] = method_exists($bundled_item, 'get_override_description') && $bundled_item->get_override_description() ? 'Yes' : 'No'; |
| 993 |
// $override_title_values[] = method_exists($bundled_item, 'get_override_title_value') ? $bundled_item->get_override_title_value() : ''; |
| 994 |
// $override_description_values[] = method_exists($bundled_item, 'get_override_description_value') ? $bundled_item->get_override_description_value() : ''; |
| 995 |
// } |
| 996 |
|
| 997 |
// // Prepare export data |
| 998 |
// WooCommerceExport::$export_instance->data[$id]['product_bundle_items'] = implode('|', $bundle_items) ?? ''; |
| 999 |
// WooCommerceExport::$export_instance->data[$id]['optional'] = implode('|', $optional_values) ?? ''; |
| 1000 |
// WooCommerceExport::$export_instance->data[$id]['quantity_min'] = implode('|', $quantity_min) ?? ''; |
| 1001 |
// WooCommerceExport::$export_instance->data[$id]['quantity_max'] = implode('|', $quantity_max) ?? ''; |
| 1002 |
// WooCommerceExport::$export_instance->data[$id]['priced_individually'] = implode('|', $price_values) ?? ''; |
| 1003 |
// WooCommerceExport::$export_instance->data[$id]['discount'] = implode('|', $discount_values) ?? ''; |
| 1004 |
// WooCommerceExport::$export_instance->data[$id]['single_product_visibility'] = implode('|', $product_values) ?? ''; |
| 1005 |
// WooCommerceExport::$export_instance->data[$id]['cart_visibility'] = implode('|', $cart_values) ?? ''; |
| 1006 |
// WooCommerceExport::$export_instance->data[$id]['order_visibility'] = implode('|', $order_values) ?? ''; |
| 1007 |
// WooCommerceExport::$export_instance->data[$id]['single_product_price_visibility'] = implode('|', $product_price_values) ?? ''; |
| 1008 |
// WooCommerceExport::$export_instance->data[$id]['cart_price_visibility'] = implode('|', $cart_price_values) ?? ''; |
| 1009 |
// WooCommerceExport::$export_instance->data[$id]['order_price_visibility'] = implode('|', $order_price_values) ?? ''; |
| 1010 |
// WooCommerceExport::$export_instance->data[$id]['hide_thumbnail'] = implode('|', $thumb_values) ?? ''; |
| 1011 |
// WooCommerceExport::$export_instance->data[$id]['override_title'] = implode('|', $override_values) ?? ''; |
| 1012 |
// WooCommerceExport::$export_instance->data[$id]['override_description'] = implode('|', $description_values) ?? ''; |
| 1013 |
// WooCommerceExport::$export_instance->data[$id]['override_title_value'] = implode('|', $override_title_values) ?? ''; |
| 1014 |
// WooCommerceExport::$export_instance->data[$id]['override_description_value'] = implode('|', $override_description_values) ?? ''; |
| 1015 |
// WooCommerceExport::$export_instance->data[$id]['pb_sale_price'] = $bundle_product->get_sale_price() ?? ''; |
| 1016 |
// WooCommerceExport::$export_instance->data[$id]['pb_regular_price'] = $bundle_product->get_regular_price() ?? ''; |
| 1017 |
// WooCommerceExport::$export_instance->data[$id]['min_bundle_size'] = $min_bundle_size ?? ''; |
| 1018 |
// WooCommerceExport::$export_instance->data[$id]['max_bundle_size'] = $max_bundle_size ?? ''; |
| 1019 |
// WooCommerceExport::$export_instance->data[$id]['edit_in_cart'] = $edit_in_cart ?? ''; |
| 1020 |
// WooCommerceExport::$export_instance->data[$id]['layout'] = $layout ?? ''; |
| 1021 |
// WooCommerceExport::$export_instance->data[$id]['item_grouping'] = $item_grouping ?? ''; |
| 1022 |
// } |
| 1023 |
// } |
| 1024 |
|
| 1025 |
// } |
| 1026 |
public function getProductData($id, $type, $optionalType) |
| 1027 |
{ |
| 1028 |
global $wpdb; |
| 1029 |
$product = wc_get_product($id); |
| 1030 |
|
| 1031 |
if(!empty($product)){ |
| 1032 |
$booking_type =''; |
| 1033 |
$product_type = $product->get_type(); |
| 1034 |
if($product_type == 'variation'){ |
| 1035 |
$parent_id = $product->get_parent_id(); |
| 1036 |
$parent_product = wc_get_product($parent_id); |
| 1037 |
$parent_sku = $parent_product->get_sku(); |
| 1038 |
WooCommerceExport::$export_instance->data[$id]['parent'] = $parent_sku; |
| 1039 |
} |
| 1040 |
$product_datas = $product->get_data(); |
| 1041 |
$product_sku = $product->get_sku(); |
| 1042 |
WooCommerceExport::$export_instance->data[$id]['PRODUCTSKU'] = $product_sku ?? ''; |
| 1043 |
$product_attributes = $product->get_attributes(); |
| 1044 |
if($product_type !=='variation'){ |
| 1045 |
if (!empty($product_attributes)) { |
| 1046 |
$count =count($product_attributes); |
| 1047 |
$new_attr_array =array(); |
| 1048 |
foreach ($product_attributes as $attribute_key => $attribute) { |
| 1049 |
$new_attr_array[] = $attribute; |
| 1050 |
} |
| 1051 |
array_unshift($new_attr_array,""); |
| 1052 |
unset($new_attr_array[0]); |
| 1053 |
$att_values = []; |
| 1054 |
$stored_id = []; |
| 1055 |
if(!empty($new_attr_array)){ |
| 1056 |
foreach ($new_attr_array as $attribute_key => $attribute) { |
| 1057 |
if (is_a($attribute, 'WC_Product_Attribute')) { |
| 1058 |
if(strpos($attribute['name'],'pa_') !== false){ |
| 1059 |
$attr_name = str_replace('pa_', '', $attribute['name']); |
| 1060 |
$attr_name = $wpdb->get_var("SELECT attribute_label FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name='$attr_name'"); |
| 1061 |
} |
| 1062 |
else{ |
| 1063 |
$attr_name = $attribute['name']; |
| 1064 |
} |
| 1065 |
$swatch_values = []; |
| 1066 |
|
| 1067 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_name'.$attribute_key]= $attr_name; |
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
$taxonomy_name = $attribute['taxonomy']; |
| 1072 |
$attribute_options = $attribute['options']; |
| 1073 |
$term_names = $att_values = array(); |
| 1074 |
foreach ($attribute_options as $term_key => $term_id) { |
| 1075 |
if(is_numeric($term_id)){ |
| 1076 |
$term = get_term_by('id', $term_id, $taxonomy_name); |
| 1077 |
if (!empty($term->name)) { |
| 1078 |
$term_names[] = $term->name; |
| 1079 |
// Retrieve swatch type and value if available |
| 1080 |
if(is_plugin_active( 'woo-variation-swatches/woo-variation-swatches.php' ) || is_plugin_active( 'woo-variation-swatches-pro/woo-variation-swatches.php' )){ |
| 1081 |
$term_meta = $wpdb->get_results("SELECT meta_key,meta_value FROM {$wpdb->termmeta} WHERE term_id = $term->term_id ",ARRAY_A); |
| 1082 |
$attri_type = $wpdb->get_results( "SELECT attribute_type FROM {$wpdb->prefix}woocommerce_attribute_taxonomies where attribute_label = '$attr_name' ",ARRAY_A); |
| 1083 |
$attri_type = !empty($attri_type[0]['attribute_type']) ? $attri_type[0]['attribute_type'] : ''; |
| 1084 |
$term_meta = end($term_meta); |
| 1085 |
$swatch_value = ''; |
| 1086 |
$swatch_types = [ |
| 1087 |
'product_attribute_color' => 'color', |
| 1088 |
'product_attribute_image' => 'image', |
| 1089 |
'product_attribute_button' => 'button', |
| 1090 |
'product_attribute_radio' => 'radio' |
| 1091 |
]; |
| 1092 |
|
| 1093 |
if (!empty($term_meta) && array_key_exists($term_meta['meta_key'], $swatch_types)) { |
| 1094 |
$swatch_type = $swatch_types[$term_meta['meta_key']]; |
| 1095 |
$swatch_value = $term_meta['meta_value']; |
| 1096 |
} else { |
| 1097 |
$swatch_type = ''; |
| 1098 |
$swatch_value = ''; |
| 1099 |
} |
| 1100 |
$swatch_values[] = !empty($swatch_value) ? $term->name . '->' . $swatch_value : ''; |
| 1101 |
} |
| 1102 |
|
| 1103 |
} |
| 1104 |
|
| 1105 |
} |
| 1106 |
else{ |
| 1107 |
$term_names [] = $term_id; |
| 1108 |
} |
| 1109 |
} |
| 1110 |
|
| 1111 |
|
| 1112 |
if (is_array($swatch_values) && array_filter($swatch_values)) { |
| 1113 |
$attribute_name = $attr_name . '->' . $swatch_type; |
| 1114 |
$att_values = implode(',', $swatch_values); |
| 1115 |
} else { |
| 1116 |
if (!empty($attri_type) && !empty($term_names) && !empty($swatch_type)) { |
| 1117 |
$attribute_name = $attr_name . '->' . $attri_type; |
| 1118 |
$att_values = implode(',', $term_names); |
| 1119 |
} else if (!empty($term_names)) { |
| 1120 |
$attr_name = $wpdb->get_var("SELECT attribute_label FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name='$attr_name'"); |
| 1121 |
$attribute_name = $attr_name; |
| 1122 |
$att_values = implode(',', $term_names); |
| 1123 |
} |
| 1124 |
} |
| 1125 |
if (is_plugin_active('woo-variation-swatches/woo-variation-swatches.php') || is_plugin_active('woo-variation-swatches-pro/woo-variation-swatches.php')) { |
| 1126 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_name' . $attribute_key] = $attribute_name; |
| 1127 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_value' . $attribute_key] = $att_values; |
| 1128 |
}else{ |
| 1129 |
$att_values = implode(',', $term_names); |
| 1130 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_value' . $attribute_key] = $att_values; |
| 1131 |
} |
| 1132 |
// if (!empty($term_names)) { |
| 1133 |
// $att_values = implode(',', $term_names); |
| 1134 |
// } |
| 1135 |
|
| 1136 |
|
| 1137 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_visible' . $attribute_key] = $attribute['is_visible']; |
| 1138 |
$is_variation[] = $attribute['is_variation']; |
| 1139 |
$position[] = $attribute['position']; |
| 1140 |
$is_taxonomy[] = $attribute['is_taxonomy']; |
| 1141 |
} |
| 1142 |
|
| 1143 |
} |
| 1144 |
} |
| 1145 |
} |
| 1146 |
} |
| 1147 |
else{ |
| 1148 |
if (!empty($product_attributes)) { |
| 1149 |
$i=1; |
| 1150 |
foreach ($product_attributes as $attribute_key => $attribute) { |
| 1151 |
$attr_name = str_replace('pa_', '', $attribute_key); |
| 1152 |
$attr_name = $wpdb->get_var("SELECT attribute_label FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name='$attr_name'"); |
| 1153 |
$attr_value = $wpdb->get_var("SELECT name FROM {$wpdb->prefix}terms WHERE slug = '$attribute'"); |
| 1154 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_name'.$i] = $attr_name; |
| 1155 |
WooCommerceExport::$export_instance->data[$id]['product_attribute_value'.$i] = $attr_value; |
| 1156 |
$i++; |
| 1157 |
} |
| 1158 |
} |
| 1159 |
} |
| 1160 |
|
| 1161 |
|
| 1162 |
$get_catalog_visibility = $product->get_catalog_visibility(); |
| 1163 |
$visibility_mapping = array('visible' => '1','catalog' => '2','search' => '3','hidden' => '4'); |
| 1164 |
WooCommerceExport::$export_instance->data[$id]['visibility'] = array_key_exists($get_catalog_visibility,$visibility_mapping) ? $visibility_mapping[$get_catalog_visibility] : ''; |
| 1165 |
|
| 1166 |
$tax_status = $product->get_tax_status(); |
| 1167 |
$tax_status_mapping = array('taxable' => 1 , 'shipping' => 2, 'none' => 3); |
| 1168 |
WooCommerceExport::$export_instance->data[$id]['tax_status'] = array_key_exists($tax_status,$tax_status_mapping) ? $tax_status_mapping[$tax_status] : '' ; |
| 1169 |
|
| 1170 |
$product_type = $product->get_type(); |
| 1171 |
$product_type_mapping = array('simple' => 1 , 'grouped' => 2, 'external' => 3, 'variable' => 4 , 'subscription' => 5 , 'variable-subscription' => 6 ,'bundle' => 7,'variation' => '8' , 'jet_booking' => 9); |
| 1172 |
WooCommerceExport::$export_instance->data[$id]['product_type'] = array_key_exists($product_type,$product_type_mapping) ? $product_type_mapping[$product_type] : '' ; |
| 1173 |
|
| 1174 |
if (has_term('featured', 'product_visibility', $id)) { |
| 1175 |
WooCommerceExport::$export_instance->data[$id]['featured_product'] = '1'; |
| 1176 |
} |
| 1177 |
WooCommerceExport::$export_instance->data[$id]['tax_class'] = $product_datas['tax_class'] ?? ''; |
| 1178 |
if (method_exists($product, 'get_file_paths')) { |
| 1179 |
$file_paths = $product->get_file_paths(); |
| 1180 |
WooCommerceExport::$export_instance->data[$id]['_file_paths'] = isset($file_paths) ? $file_paths : ''; |
| 1181 |
} else { |
| 1182 |
WooCommerceExport::$export_instance->data[$id]['_file_paths'] = ''; |
| 1183 |
} |
| 1184 |
$edit_last = get_post_meta($id, '_edit_last', true); |
| 1185 |
WooCommerceExport::$export_instance->data[$id]['_edit_last'] = $edit_last ?? ''; |
| 1186 |
$edit_lock = get_post_meta($id, '_edit_lock', true); |
| 1187 |
WooCommerceExport::$export_instance->data[$id]['_edit_lock'] = $edit_lock ?? ''; |
| 1188 |
$thumbnail_id = get_post_thumbnail_id($product->get_id()); |
| 1189 |
$attachment_url = wp_get_attachment_url($thumbnail_id); |
| 1190 |
WooCommerceExport::$export_instance->data[$id]['_thumbnail_id'] = $attachment_url ?? ''; |
| 1191 |
WooCommerceExport::$export_instance->data[$id]['manage_stock'] = $product->get_manage_stock() ? '1' : ''; |
| 1192 |
$stock_quantity = $product->get_stock_quantity(); |
| 1193 |
$stock_status = $product->get_stock_status(); |
| 1194 |
$low_stock_threshold = $product->get_low_stock_amount(); |
| 1195 |
$total_sales = $product->get_total_sales(); |
| 1196 |
WooCommerceExport::$export_instance->data[$id]['_stock'] = $stock_quantity ?? ''; |
| 1197 |
WooCommerceExport::$export_instance->data[$id]['_stock_status'] = $stock_status ?? ''; |
| 1198 |
WooCommerceExport::$export_instance->data[$id]['_low_stock_threshold'] = $low_stock_threshold ?? ''; |
| 1199 |
WooCommerceExport::$export_instance->data[$id]['_total_sales'] = $total_sales ?? ''; |
| 1200 |
$downloadable = $product->is_downloadable() ? 'yes' : 'no'; |
| 1201 |
$virtual = $product->is_virtual() ? 'yes' : 'no'; |
| 1202 |
$regular_price = $product->get_regular_price(); |
| 1203 |
$sale_price = $product->get_sale_price(); |
| 1204 |
$purchase_note = $product->get_purchase_note(); |
| 1205 |
|
| 1206 |
WooCommerceExport::$export_instance->data[$id]['_downloadable'] = $downloadable ?? ''; |
| 1207 |
WooCommerceExport::$export_instance->data[$id]['_virtual'] = $virtual ?? ''; |
| 1208 |
WooCommerceExport::$export_instance->data[$id]['_regular_price'] = $regular_price ?? ''; |
| 1209 |
WooCommerceExport::$export_instance->data[$id]['_sale_price'] = $sale_price ?? ''; |
| 1210 |
WooCommerceExport::$export_instance->data[$id]['_purchase_note'] = $purchase_note ?? ''; |
| 1211 |
|
| 1212 |
$weight = $product->get_weight(); |
| 1213 |
$length = $product->get_length(); |
| 1214 |
$width = $product->get_width(); |
| 1215 |
$height = $product->get_height(); |
| 1216 |
$upsell_ids = $product->get_upsell_ids(); |
| 1217 |
$upsell_product_names = []; |
| 1218 |
foreach ($upsell_ids as $up_id) { |
| 1219 |
$upsell_product = wc_get_product($up_id); |
| 1220 |
$upsell_product_names[] = $upsell_product ? $upsell_product->get_name() : ''; |
| 1221 |
} |
| 1222 |
$cross_sell_ids = $product->get_cross_sell_ids(); |
| 1223 |
$cross_sell_product_names = []; |
| 1224 |
foreach ($cross_sell_ids as $cross_id) { |
| 1225 |
$cross_sell_product = wc_get_product($cross_id); |
| 1226 |
$cross_sell_product_names[] = $cross_sell_product ? $cross_sell_product->get_name() : ''; |
| 1227 |
} |
| 1228 |
WooCommerceExport::$export_instance->data[$id]['weight'] = $weight ?? ''; |
| 1229 |
WooCommerceExport::$export_instance->data[$id]['length'] = $length ?? ''; |
| 1230 |
WooCommerceExport::$export_instance->data[$id]['width'] = $width ?? ''; |
| 1231 |
WooCommerceExport::$export_instance->data[$id]['height'] = $height ?? ''; |
| 1232 |
WooCommerceExport::$export_instance->data[$id]['upsell_ids'] = !empty($upsell_product_names) ? implode(',', $upsell_product_names) : ''; |
| 1233 |
WooCommerceExport::$export_instance->data[$id]['crosssell_ids'] = !empty($cross_sell_product_names) ? implode(',', $cross_sell_product_names) : ''; |
| 1234 |
|
| 1235 |
$grouping_product_ids = []; // Initialize an array to store child product IDs |
| 1236 |
if ($product->is_type('grouped')) { |
| 1237 |
$children = $product->get_children(); |
| 1238 |
foreach ($children as $child_id) { |
| 1239 |
$child = wc_get_product($child_id); |
| 1240 |
if (!empty($child)) { |
| 1241 |
$grouping_product_ids[] = $child_id; |
| 1242 |
} |
| 1243 |
} |
| 1244 |
} |
| 1245 |
$grouping_product_ids_string = !empty($grouping_product_ids) ? implode(',', $grouping_product_ids) : ''; |
| 1246 |
WooCommerceExport::$export_instance->data[$id]['grouping_product'] = $grouping_product_ids_string; |
| 1247 |
|
| 1248 |
$sale_price_dates_from = $product->get_date_on_sale_from(); |
| 1249 |
$sale_price_dates_to = $product->get_date_on_sale_to(); |
| 1250 |
$sold_individually = $product->get_sold_individually(); |
| 1251 |
$backorders = $product->get_backorders(); |
| 1252 |
switch ($backorders) { |
| 1253 |
case 'no': |
| 1254 |
$backorders_no= '1'; |
| 1255 |
break; |
| 1256 |
|
| 1257 |
case 'notify': |
| 1258 |
$backorders_no= '2'; |
| 1259 |
break; |
| 1260 |
|
| 1261 |
case 'yes': |
| 1262 |
$backorders_no = '3'; |
| 1263 |
break; |
| 1264 |
|
| 1265 |
default: |
| 1266 |
$backorders_no = ''; |
| 1267 |
break; |
| 1268 |
} |
| 1269 |
WooCommerceExport::$export_instance->data[$id]['sale_price_dates_from'] = $sale_price_dates_from ?? ''; |
| 1270 |
WooCommerceExport::$export_instance->data[$id]['sale_price_dates_to'] = $sale_price_dates_to ?? ''; |
| 1271 |
WooCommerceExport::$export_instance->data[$id]['sold_individually'] = ($sold_individually > 0) ? 'yes' : 'no'; |
| 1272 |
WooCommerceExport::$export_instance->data[$id]['backorders'] = $backorders_no; |
| 1273 |
// $product_url = ($product->is_type('external')) ? $product->get_product_url() : ''; |
| 1274 |
$product_url = get_permalink($id); |
| 1275 |
|
| 1276 |
$button_text = ($product->is_type('external')) ? $product->single_add_to_cart_text() : ''; |
| 1277 |
$featured = get_post_meta($product->get_id(), 'featured', true) ? '1' : '0'; |
| 1278 |
WooCommerceExport::$export_instance->data[$id]['product_url'] = $product_url; |
| 1279 |
WooCommerceExport::$export_instance->data[$id]['button_text'] = $button_text; |
| 1280 |
WooCommerceExport::$export_instance->data[$id]['featured'] = $featured; |
| 1281 |
$downloadable_files = []; |
| 1282 |
$download_type = []; |
| 1283 |
if(($product->is_type('variable'))){ |
| 1284 |
$download_limits = []; |
| 1285 |
$download_expiries = []; |
| 1286 |
$variations = $product->get_children(); |
| 1287 |
foreach ($variations as $variation_id) { |
| 1288 |
$variation = wc_get_product($variation_id); |
| 1289 |
// Check if the variation is downloadable |
| 1290 |
if ($variation->is_downloadable()) { |
| 1291 |
$downloads = $variation->get_downloads(); |
| 1292 |
foreach ($downloads as $download) { |
| 1293 |
$file_url = $download->get_file(); // Get the file URL |
| 1294 |
$file_name = $download->get_name(); // Get the file name |
| 1295 |
$file_string = $file_name.','.$file_url; |
| 1296 |
$downloadable_files[] = $file_string; |
| 1297 |
if (strpos($file_url, 'http') === 0) { |
| 1298 |
$download_type[] = 'external'; // If URL starts with http, it's an external URL |
| 1299 |
} else { |
| 1300 |
$download_type[] = 'file'; // Otherwise, it's a file URL |
| 1301 |
} |
| 1302 |
|
| 1303 |
} |
| 1304 |
$download_limit = $variation->get_download_limit(); // Default is -1 for unlimited |
| 1305 |
$download_expiry = $variation->get_download_expiry(); // Default is -1 for no expiry |
| 1306 |
// Store the values |
| 1307 |
$download_limits[] = $download_limit; |
| 1308 |
$download_expiries[] = $download_expiry; |
| 1309 |
|
| 1310 |
} |
| 1311 |
$download_limit = !empty($download_limit) ? implode('|', $download_limits) : ''; |
| 1312 |
$download_expiry = !empty($download_expiry) ? implode('|', $download_expiries) : ''; |
| 1313 |
$download_type_str = !empty($download_type) ? implode('|', $download_type) : ''; |
| 1314 |
$download_file_str = !empty($downloadable_files) ? implode('|', $downloadable_files) : ''; |
| 1315 |
} |
| 1316 |
}else{ |
| 1317 |
$downloads = $product->get_downloads(); |
| 1318 |
foreach ($downloads as $download) { |
| 1319 |
$file_string = $download['name'].','.$download['file']; |
| 1320 |
$downloadable_files[] = $file_string; |
| 1321 |
if (strpos($download['file'], 'http') === 0) { |
| 1322 |
$download_type[] = 'external'; // If URL starts with http, it's an external URL |
| 1323 |
} else { |
| 1324 |
$download_type[] = 'file'; // Otherwise, it's a file URL |
| 1325 |
} |
| 1326 |
} |
| 1327 |
$download_type_str = !empty($download_type) ? implode('|', $download_type) : ''; |
| 1328 |
$download_file_str = !empty($downloadable_files) ? implode('|', $downloadable_files) : ''; |
| 1329 |
|
| 1330 |
$download_limit = $product->get_download_limit(); |
| 1331 |
$download_expiry = $product->get_download_expiry(); |
| 1332 |
} |
| 1333 |
|
| 1334 |
WooCommerceExport::$export_instance->data[$id]['downloadable_files'] = $download_file_str; |
| 1335 |
WooCommerceExport::$export_instance->data[$id]['download_limit'] = ($download_limit > -1) ? $download_limit : ''; |
| 1336 |
WooCommerceExport::$export_instance->data[$id]['download_expiry'] = ($download_expiry > -1) ? $download_expiry : ''; |
| 1337 |
WooCommerceExport::$export_instance->data[$id]['download_type'] = $download_type_str; |
| 1338 |
|
| 1339 |
$subscription_period = get_post_meta($id, '_subscription_period', true); |
| 1340 |
$subscription_period_interval = get_post_meta($id, '_subscription_period_interval', true); |
| 1341 |
$subscription_length = get_post_meta($id, '_subscription_length', true); |
| 1342 |
$subscription_trial_period = get_post_meta($id, '_subscription_trial_period', true); |
| 1343 |
$subscription_trial_length = get_post_meta($id, '_subscription_trial_length', true); |
| 1344 |
$subscription_price = get_post_meta($id, '_subscription_price', true); |
| 1345 |
$subscription_sign_up_fee = get_post_meta($id, '_subscription_sign_up_fee', true); |
| 1346 |
|
| 1347 |
WooCommerceExport::$export_instance->data[$id]['_subscription_period'] = $subscription_period ?? ''; |
| 1348 |
WooCommerceExport::$export_instance->data[$id]['_subscription_period_interval'] = $subscription_period_interval ?? ''; |
| 1349 |
WooCommerceExport::$export_instance->data[$id]['_subscription_length'] = $subscription_length ?? ''; |
| 1350 |
WooCommerceExport::$export_instance->data[$id]['_subscription_trial_period'] = $subscription_trial_period ?? ''; |
| 1351 |
WooCommerceExport::$export_instance->data[$id]['_subscription_trial_length'] = $subscription_trial_length ?? ''; |
| 1352 |
WooCommerceExport::$export_instance->data[$id]['_subscription_price'] = $subscription_price ?? ''; |
| 1353 |
WooCommerceExport::$export_instance->data[$id]['_subscription_sign_up_fee'] = $subscription_sign_up_fee ?? ''; |
| 1354 |
|
| 1355 |
if ( is_plugin_active( 'yith-woocommerce-barcodes-premium/init.php' )){ |
| 1356 |
// Retrieve barcode details |
| 1357 |
$barcode_protocol = get_post_meta($id, '_ywbc_barcode_protocol', true); |
| 1358 |
$barcode_value = get_post_meta($id, '_ywbc_barcode_value', true); |
| 1359 |
$barcode_display_value = get_post_meta($id, '_ywbc_barcode_display_value', true); |
| 1360 |
WooCommerceExport::$export_instance->data[$id]['_ywbc_barcode_display_value'] = $barcode_display_value ?? ''; |
| 1361 |
WooCommerceExport::$export_instance->data[$id]['_ywbc_barcode_value'] = $barcode_value ?? ''; |
| 1362 |
WooCommerceExport::$export_instance->data[$id]['_ywbc_barcode_protocol'] = $barcode_protocol ?? ''; |
| 1363 |
} |
| 1364 |
|
| 1365 |
|
| 1366 |
} |
| 1367 |
|
| 1368 |
// //woocommerce-product-bundles plugin |
| 1369 |
if (is_plugin_active('woocommerce-product-bundles/woocommerce-product-bundles.php')) { |
| 1370 |
// Get the bundle product |
| 1371 |
$bundle_product = wc_get_product($id); |
| 1372 |
|
| 1373 |
if ($bundle_product && $bundle_product->is_type('bundle')) { |
| 1374 |
// Initialize default values |
| 1375 |
$bundle_items = array(); |
| 1376 |
$optional_values = array(); |
| 1377 |
$quantity_min = array(); |
| 1378 |
$quantity_max = array(); |
| 1379 |
$price_values = array(); |
| 1380 |
$discount_values = array(); |
| 1381 |
$product_values = array(); |
| 1382 |
$cart_values = array(); |
| 1383 |
$order_values = array(); |
| 1384 |
$product_price_values = array(); |
| 1385 |
$cart_price_values = array(); |
| 1386 |
$order_price_values = array(); |
| 1387 |
$thumb_values = array(); |
| 1388 |
$override_values = array(); |
| 1389 |
$description_values = array(); |
| 1390 |
$override_title_values = array(); |
| 1391 |
$override_description_values = array(); |
| 1392 |
|
| 1393 |
// Get bundle settings |
| 1394 |
$min_bundle_size = $bundle_product->get_min_bundle_size(); |
| 1395 |
$max_bundle_size = $bundle_product->get_max_bundle_size(); |
| 1396 |
$edit_in_cart = $bundle_product->get_editable_in_cart() ? 'Yes' : 'No'; |
| 1397 |
$layout = $bundle_product->get_layout(); // Assuming this method exists |
| 1398 |
$get_mode = $bundle_product->get_group_mode(); |
| 1399 |
if($get_mode == 'noindent'){ |
| 1400 |
$item_grouping = 'flat'; |
| 1401 |
}else if($get_mode == 'parent'){ |
| 1402 |
$item_grouping = 'grouped'; |
| 1403 |
}else{ |
| 1404 |
$item_grouping = ''; |
| 1405 |
} |
| 1406 |
foreach ($bundle_product->get_bundled_items() as $bundled_item) { |
| 1407 |
// Get bundled item product |
| 1408 |
$bundled_product = $bundled_item->get_product(); |
| 1409 |
$bundle_items[] = $bundled_product->get_name(); |
| 1410 |
|
| 1411 |
// Retrieve settings for each bundled item |
| 1412 |
$optional_values[] = method_exists($bundled_item, 'is_optional') && $bundled_item->is_optional() ? 'Yes' : 'No'; |
| 1413 |
$quantity_min[] = method_exists($bundled_item, 'get_min_quantity') ? $bundled_item->get_min_quantity() : ''; |
| 1414 |
$quantity_max[] = method_exists($bundled_item, 'get_max_quantity') ? $bundled_item->get_max_quantity() : ''; |
| 1415 |
$price_values[] = method_exists($bundled_item, 'is_priced_individually') && $bundled_item->is_priced_individually() ? 'Yes' : 'No'; |
| 1416 |
$discount_values[] = method_exists($bundled_item, 'get_discount') ? $bundled_item->get_discount() : ''; |
| 1417 |
$product_values[] = method_exists($bundled_item, 'get_single_product_visibility') && $bundled_item->get_single_product_visibility() ? 'Yes' : 'No'; |
| 1418 |
$cart_values[] = method_exists($bundled_item, 'get_cart_visibility') && $bundled_item->get_cart_visibility() ? 'Yes' : 'No'; |
| 1419 |
$order_values[] = method_exists($bundled_item, 'get_order_visibility') && $bundled_item->get_order_visibility() ? 'Yes' : 'No'; |
| 1420 |
$product_price_values[] = method_exists($bundled_item, 'get_single_product_price_visibility') && $bundled_item->get_single_product_price_visibility() ? 'Yes' : 'No'; |
| 1421 |
$cart_price_values[] = method_exists($bundled_item, 'get_cart_price_visibility') && $bundled_item->get_cart_price_visibility() ? 'Yes' : 'No'; |
| 1422 |
$order_price_values[] = method_exists($bundled_item, 'get_order_price_visibility') && $bundled_item->get_order_price_visibility() ? 'Yes' : 'No'; |
| 1423 |
$thumb_values[] = method_exists($bundled_item, 'get_hide_thumbnail') && $bundled_item->get_hide_thumbnail() ? 'Yes' : 'No'; |
| 1424 |
$override_values[] = method_exists($bundled_item, 'get_override_title') && $bundled_item->get_override_title() ? 'Yes' : 'No'; |
| 1425 |
$description_values[] = method_exists($bundled_item, 'get_override_description') && $bundled_item->get_override_description() ? 'Yes' : 'No'; |
| 1426 |
$override_title_values[] = method_exists($bundled_item, 'get_override_title_value') ? $bundled_item->get_override_title_value() : ''; |
| 1427 |
$override_description_values[] = method_exists($bundled_item, 'get_override_description_value') ? $bundled_item->get_override_description_value() : ''; |
| 1428 |
} |
| 1429 |
|
| 1430 |
// Prepare export data |
| 1431 |
WooCommerceExport::$export_instance->data[$id]['product_bundle_items'] = implode('|', $bundle_items) ?? ''; |
| 1432 |
WooCommerceExport::$export_instance->data[$id]['optional'] = implode('|', $optional_values) ?? ''; |
| 1433 |
WooCommerceExport::$export_instance->data[$id]['quantity_min'] = implode('|', $quantity_min) ?? ''; |
| 1434 |
WooCommerceExport::$export_instance->data[$id]['quantity_max'] = implode('|', $quantity_max) ?? ''; |
| 1435 |
WooCommerceExport::$export_instance->data[$id]['priced_individually'] = implode('|', $price_values) ?? ''; |
| 1436 |
WooCommerceExport::$export_instance->data[$id]['discount'] = implode('|', $discount_values) ?? ''; |
| 1437 |
WooCommerceExport::$export_instance->data[$id]['single_product_visibility'] = implode('|', $product_values) ?? ''; |
| 1438 |
WooCommerceExport::$export_instance->data[$id]['cart_visibility'] = implode('|', $cart_values) ?? ''; |
| 1439 |
WooCommerceExport::$export_instance->data[$id]['order_visibility'] = implode('|', $order_values) ?? ''; |
| 1440 |
WooCommerceExport::$export_instance->data[$id]['single_product_price_visibility'] = implode('|', $product_price_values) ?? ''; |
| 1441 |
WooCommerceExport::$export_instance->data[$id]['cart_price_visibility'] = implode('|', $cart_price_values) ?? ''; |
| 1442 |
WooCommerceExport::$export_instance->data[$id]['order_price_visibility'] = implode('|', $order_price_values) ?? ''; |
| 1443 |
WooCommerceExport::$export_instance->data[$id]['hide_thumbnail'] = implode('|', $thumb_values) ?? ''; |
| 1444 |
WooCommerceExport::$export_instance->data[$id]['override_title'] = implode('|', $override_values) ?? ''; |
| 1445 |
WooCommerceExport::$export_instance->data[$id]['override_description'] = implode('|', $description_values) ?? ''; |
| 1446 |
WooCommerceExport::$export_instance->data[$id]['override_title_value'] = implode('|', $override_title_values) ?? ''; |
| 1447 |
WooCommerceExport::$export_instance->data[$id]['override_description_value'] = implode('|', $override_description_values) ?? ''; |
| 1448 |
WooCommerceExport::$export_instance->data[$id]['pb_sale_price'] = $bundle_product->get_sale_price() ?? ''; |
| 1449 |
WooCommerceExport::$export_instance->data[$id]['pb_regular_price'] = $bundle_product->get_regular_price() ?? ''; |
| 1450 |
WooCommerceExport::$export_instance->data[$id]['min_bundle_size'] = $min_bundle_size ?? ''; |
| 1451 |
WooCommerceExport::$export_instance->data[$id]['max_bundle_size'] = $max_bundle_size ?? ''; |
| 1452 |
WooCommerceExport::$export_instance->data[$id]['edit_in_cart'] = $edit_in_cart ?? ''; |
| 1453 |
WooCommerceExport::$export_instance->data[$id]['layout'] = $layout ?? ''; |
| 1454 |
WooCommerceExport::$export_instance->data[$id]['item_grouping'] = $item_grouping ?? ''; |
| 1455 |
} |
| 1456 |
} |
| 1457 |
|
| 1458 |
} |
| 1459 |
|
| 1460 |
/** |
| 1461 |
* Fetch Terms & Taxonomies |
| 1462 |
* @param $mode |
| 1463 |
* @param $module |
| 1464 |
* @param $optionalType |
| 1465 |
* @return array |
| 1466 |
*/ |
| 1467 |
public function FetchTaxonomies($module, $optionalType, $mode = null) { |
| 1468 |
|
| 1469 |
global $wpdb; |
| 1470 |
$terms_table = $wpdb->prefix."terms"; |
| 1471 |
$terms_taxo_table = $wpdb->prefix."term_taxonomy"; |
| 1472 |
self::$export_instance->generateHeaders($module, $optionalType); |
| 1473 |
$taxonomy = $optionalType; |
| 1474 |
$query = $wpdb->prepare("SELECT * FROM $terms_table t INNER JOIN $terms_taxo_table tax ON `tax`.term_id = `t`.term_id WHERE `tax`.taxonomy = %s ", $taxonomy); |
| 1475 |
|
| 1476 |
$get_all_taxonomies = $wpdb->get_results($query); |
| 1477 |
self::$export_instance->totalRowCount = count($get_all_taxonomies); |
| 1478 |
if(!empty($get_all_taxonomies)) { |
| 1479 |
foreach( $get_all_taxonomies as $termKey => $termValue ) { |
| 1480 |
$termID = $termValue->term_id; |
| 1481 |
$termMeta = get_term_meta($termID); |
| 1482 |
//wpsc_meta data starts |
| 1483 |
if(in_array('wp-e-commerce/wp-shopping-cart.php', self::$export_instance->get_active_plugins())) { |
| 1484 |
$wpsc_query = $wpdb->prepare("select meta_key,meta_value from {$wpdb->prefix}wpsc_meta where object_id = %d AND object_type = %s", $termID, 'wpsc_category'); |
| 1485 |
$wpsc_meta = $wpdb->get_results($wpsc_query,ARRAY_A); |
| 1486 |
foreach($wpsc_meta as $mk => $mv){ |
| 1487 |
if($mv['meta_key'] == 'image'){ |
| 1488 |
if($mv['meta_value']){ |
| 1489 |
$udir = wp_upload_dir(); |
| 1490 |
$img_path = $udir['baseurl'] . "/wpsc/category_images/".$mv['meta_value']; |
| 1491 |
self::$export_instance->data[$termID]['category_image'] = $img_path; |
| 1492 |
}else{ |
| 1493 |
self::$export_instance->data[$termID]['category_image'] = ''; |
| 1494 |
} |
| 1495 |
}elseif($mv['meta_key'] == 'display_type'){ |
| 1496 |
self::$export_instance->data[$termID]['catelog_view'] = $mv['meta_value']; |
| 1497 |
}elseif($mv['meta_key'] == 'uses_billing_address'){ |
| 1498 |
self::$export_instance->data[$termID]['address_calculate'] = $mv['meta_value']; }elseif($mv['meta_key'] == 'image_width'){ |
| 1499 |
self::$export_instance->data[$termID]['category_image_width'] = $mv['meta_value']; }elseif($mv['meta_key'] == 'image_height'){ |
| 1500 |
self::$export_instance->data[$termID]['category_image_height'] = $mv['meta_value']; }else{ |
| 1501 |
self::$export_instance->data[$termID][$mv['meta_key']] = $mv['meta_value']; |
| 1502 |
} |
| 1503 |
} |
| 1504 |
} |
| 1505 |
//wpsc_meta data ends |
| 1506 |
//woocommerce meta data starts |
| 1507 |
if(in_array('woocommerce/woocommerce.php', self::$export_instance->get_active_plugins())){ |
| 1508 |
if(isset($termMeta['thumbnail_id'][0])){ |
| 1509 |
$thum_id = $termMeta['thumbnail_id'][0]; |
| 1510 |
self::$export_instance->data[$termID]['image'] = self::$export_instance->getAttachment($thum_id); |
| 1511 |
} |
| 1512 |
if(!empty($termMeta['display_type'][0])){ |
| 1513 |
self::$export_instance->data[$termID]['display_type'] = $termMeta['display_type'][0]; |
| 1514 |
} |
| 1515 |
if(!empty($termMeta['cat_meta'][0])){ |
| 1516 |
$cat_meta = unserialize($termMeta['cat_meta'][0]); |
| 1517 |
self::$export_instance->data[$termID]['top_content'] = $cat_meta['cat_header']; |
| 1518 |
self::$export_instance->data[$termID]['bottom_content'] = $cat_meta['cat_footer']; |
| 1519 |
} |
| 1520 |
} |
| 1521 |
//woocommerce meta data ends |
| 1522 |
$termName = $termValue->name; |
| 1523 |
$termSlug = $termValue->slug; |
| 1524 |
$termDesc = $termValue->description; |
| 1525 |
$termParent = $termValue->parent; |
| 1526 |
if($termParent == 0) { |
| 1527 |
self::$export_instance->data[$termID]['name'] = $termName; |
| 1528 |
} else { |
| 1529 |
$termParentName = get_cat_name( $termParent ); |
| 1530 |
self::$export_instance->data[$termID]['name'] = $termParentName . '|' . $termName; |
| 1531 |
} |
| 1532 |
self::$export_instance->data[$termID]['slug'] = $termSlug; |
| 1533 |
self::$export_instance->data[$termID]['description'] = $termDesc; |
| 1534 |
self::$export_instance->data[$termID]['TERMID'] = $termID; |
| 1535 |
self::$export_instance->data[$termID]['parent'] = $termParent; |
| 1536 |
self::$export_instance->getWPMLData($termID,$optionalType,$module); |
| 1537 |
|
| 1538 |
WooCommerceExport::$post_export->getPostsMetaDataBasedOnRecordId($termID, $module, $optionalType); |
| 1539 |
|
| 1540 |
if(in_array('wordpress-seo/wp-seo.php', self::$export_instance->get_active_plugins())) { |
| 1541 |
$seo_yoast_taxonomies = get_option( 'wpseo_taxonomy_meta' ); |
| 1542 |
if ( isset( $seo_yoast_taxonomies[$optionalType] ) ) { |
| 1543 |
self::$export_instance->data[ $termID ]['title'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_title']; |
| 1544 |
self::$export_instance->data[ $termID ]['meta_desc'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_desc']; |
| 1545 |
self::$export_instance->data[ $termID ]['canonical'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_canonical']; |
| 1546 |
self::$export_instance->data[ $termID ]['bctitle'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_bctitle']; |
| 1547 |
self::$export_instance->data[ $termID ]['meta-robots-noindex'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_noindex']; |
| 1548 |
self::$export_instance->data[ $termID ]['sitemap-include'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_sitemap_include']; |
| 1549 |
self::$export_instance->data[ $termID ]['opengraph-title'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_opengraph-title']; |
| 1550 |
self::$export_instance->data[ $termID ]['opengraph-description'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_opengraph-description']; |
| 1551 |
self::$export_instance->data[ $termID ]['opengraph-image'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_opengraph-image']; |
| 1552 |
self::$export_instance->data[ $termID ]['twitter-title'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_twitter-title']; |
| 1553 |
self::$export_instance->data[ $termID ]['twitter-description'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_twitter-description']; |
| 1554 |
self::$export_instance->data[ $termID ]['twitter-image'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_twitter-image']; |
| 1555 |
self::$export_instance->data[ $termID ]['focus_keyword'] = $seo_yoast_taxonomies[$optionalType][$termID]['wpseo_focuskw']; |
| 1556 |
|
| 1557 |
} |
| 1558 |
} |
| 1559 |
} |
| 1560 |
} |
| 1561 |
|
| 1562 |
$result = self::$export_instance->finalDataToExport(self::$export_instance->data , $module); |
| 1563 |
if($mode == null) |
| 1564 |
self::$export_instance->proceedExport($result); |
| 1565 |
else |
| 1566 |
return $result; |
| 1567 |
} |
| 1568 |
|
| 1569 |
public function getCourseData($id) |
| 1570 |
{ |
| 1571 |
global $wpdb; |
| 1572 |
|
| 1573 |
$get_section_details = $wpdb->get_results("SELECT section_id, section_name, section_description FROM {$wpdb->prefix}learnpress_sections WHERE section_course_id = $id ", ARRAY_A); |
| 1574 |
$section_names = ''; |
| 1575 |
$section_descriptions = ''; |
| 1576 |
$get_lesson_name = ''; |
| 1577 |
$get_lesson_description = ''; |
| 1578 |
$get_lesson_duration = ''; |
| 1579 |
$get_lesson_preview = ''; |
| 1580 |
$get_quiz_name = ''; |
| 1581 |
$get_quiz_description = ''; |
| 1582 |
$get_quiz_meta = []; |
| 1583 |
|
| 1584 |
foreach($get_section_details as $section_details){ |
| 1585 |
$section_names .= $section_details['section_name'] . '|'; |
| 1586 |
$section_descriptions .= $section_details['section_description'] . '|'; |
| 1587 |
|
| 1588 |
$section_id = $section_details['section_id']; |
| 1589 |
$get_section_item_details = $wpdb->get_results("SELECT item_id, item_type FROM {$wpdb->prefix}learnpress_section_items WHERE section_id = $section_id ", ARRAY_A); |
| 1590 |
|
| 1591 |
$lesson_name = ''; |
| 1592 |
$lesson_description = ''; |
| 1593 |
$quiz_name = ''; |
| 1594 |
$quiz_description = ''; |
| 1595 |
$lesson_duration = ''; |
| 1596 |
$lesson_preview = ''; |
| 1597 |
$quiz_metas = []; |
| 1598 |
|
| 1599 |
foreach($get_section_item_details as $section_item_details){ |
| 1600 |
$section_item_id = $section_item_details['item_id']; |
| 1601 |
if($section_item_details['item_type'] == 'lp_lesson'){ |
| 1602 |
$lesson_name .= $wpdb->get_var("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = $section_item_id ") . ', '; |
| 1603 |
$lesson_description .= $wpdb->get_var("SELECT post_content FROM {$wpdb->prefix}posts WHERE ID = $section_item_id "). ', '; |
| 1604 |
$lesson_duration .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $section_item_id AND meta_key = '_lp_duration' ") . ', '; |
| 1605 |
$lesson_preview .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $section_item_id AND meta_key = '_lp_preview' ") . ', '; |
| 1606 |
} |
| 1607 |
elseif($section_item_details['item_type'] == 'lp_quiz'){ |
| 1608 |
$quiz_name .= $wpdb->get_var("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = $section_item_id ") . ', '; |
| 1609 |
$quiz_description .= $wpdb->get_var("SELECT post_content FROM {$wpdb->prefix}posts WHERE ID = $section_item_id "). ', '; |
| 1610 |
|
| 1611 |
$quiz_meta = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $section_item_id AND meta_key LIKE '_lp_%' ", ARRAY_A); |
| 1612 |
foreach($quiz_meta as $quiz_meta_values){ |
| 1613 |
$quiz_key = $quiz_meta_values['meta_key']; |
| 1614 |
$quiz_value = $quiz_meta_values['meta_value'] . ', '; |
| 1615 |
|
| 1616 |
if($quiz_key != '_lp_hidden_questions'){ |
| 1617 |
if($quiz_key == '_lp_retake_count'){ |
| 1618 |
$quiz_key = '_lp_quiz_retake_count'; |
| 1619 |
} |
| 1620 |
$quiz_metas[$quiz_key] = $quiz_value; |
| 1621 |
} |
| 1622 |
} |
| 1623 |
} |
| 1624 |
} |
| 1625 |
|
| 1626 |
$get_lesson_name .= rtrim($lesson_name, ', ') . '|'; |
| 1627 |
$get_lesson_description .= rtrim($lesson_description, ', ') . '|'; |
| 1628 |
$get_quiz_name .= rtrim($quiz_name, ', ') . '|'; |
| 1629 |
$get_quiz_description .= rtrim($quiz_description, ', ') . '|'; |
| 1630 |
$get_lesson_duration .= rtrim($lesson_duration, ', ') . '|'; |
| 1631 |
$get_lesson_preview .= rtrim($lesson_preview, ', ') . '|'; |
| 1632 |
|
| 1633 |
foreach($quiz_metas as $quiz_meta_keys => $quiz_meta_values){ |
| 1634 |
$get_quiz_meta[$quiz_meta_keys] = rtrim($quiz_meta_values, ', ') . '|'; |
| 1635 |
} |
| 1636 |
} |
| 1637 |
|
| 1638 |
WooCommerceExport::$export_instance->data[$id]['curriculum_name'] = rtrim($section_names, '|'); |
| 1639 |
WooCommerceExport::$export_instance->data[$id]['curriculum_description'] = rtrim($section_descriptions, '|'); |
| 1640 |
WooCommerceExport::$export_instance->data[$id]['lesson_name'] = rtrim($get_lesson_name, '|'); |
| 1641 |
WooCommerceExport::$export_instance->data[$id]['lesson_description'] = rtrim($get_lesson_description, '|'); |
| 1642 |
WooCommerceExport::$export_instance->data[$id]['quiz_name'] = rtrim($get_quiz_name, '|'); |
| 1643 |
WooCommerceExport::$export_instance->data[$id]['quiz_description'] = rtrim($get_quiz_description, '|'); |
| 1644 |
WooCommerceExport::$export_instance->data[$id]['_lp_lesson_duration'] = rtrim($get_lesson_duration, '|'); |
| 1645 |
WooCommerceExport::$export_instance->data[$id]['_lp_preview'] = rtrim($get_lesson_preview, '|'); |
| 1646 |
|
| 1647 |
foreach($get_quiz_meta as $get_quiz_meta_keys => $get_quiz_meta_values){ |
| 1648 |
WooCommerceExport::$export_instance->data[$id][$get_quiz_meta_keys] = rtrim($get_quiz_meta_values, '|'); |
| 1649 |
} |
| 1650 |
} |
| 1651 |
|
| 1652 |
public function getLessonData($id){ |
| 1653 |
global $wpdb; |
| 1654 |
$lesson_duration = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id AND meta_key = '_lp_duration' "); |
| 1655 |
WooCommerceExport::$export_instance->data[$id]['_lp_lesson_duration'] = $lesson_duration; |
| 1656 |
|
| 1657 |
$get_section_id = $wpdb->get_var("SELECT section_id FROM {$wpdb->prefix}learnpress_section_items WHERE item_id = $id AND item_type = 'lp_lesson' "); |
| 1658 |
if(!empty($get_section_id)){ |
| 1659 |
$get_section_name = $wpdb->get_var("SELECT section_name FROM {$wpdb->prefix}learnpress_sections WHERE section_id = $get_section_id "); |
| 1660 |
$get_section_course_id = $wpdb->get_var("SELECT section_course_id FROM {$wpdb->prefix}learnpress_sections WHERE section_id = $get_section_id "); |
| 1661 |
|
| 1662 |
WooCommerceExport::$export_instance->data[$id]['curriculum_name'] = $get_section_name; |
| 1663 |
WooCommerceExport::$export_instance->data[$id]['course_id'] = $get_section_course_id; |
| 1664 |
} |
| 1665 |
} |
| 1666 |
|
| 1667 |
public function getQuizData($id){ |
| 1668 |
global $wpdb; |
| 1669 |
$quiz_retake_count = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id AND meta_key = '_lp_retake_count' "); |
| 1670 |
WooCommerceExport::$export_instance->data[$id]['_lp_quiz_retake_count'] = $quiz_retake_count; |
| 1671 |
|
| 1672 |
$get_section_id = $wpdb->get_var("SELECT section_id FROM {$wpdb->prefix}learnpress_section_items WHERE item_id = $id AND item_type = 'lp_quiz' "); |
| 1673 |
if(!empty($get_section_id)){ |
| 1674 |
$get_section_name = $wpdb->get_var("SELECT section_name FROM {$wpdb->prefix}learnpress_sections WHERE section_id = $get_section_id "); |
| 1675 |
$get_section_course_id = $wpdb->get_var("SELECT section_course_id FROM {$wpdb->prefix}learnpress_sections WHERE section_id = $get_section_id "); |
| 1676 |
|
| 1677 |
WooCommerceExport::$export_instance->data[$id]['curriculum_name'] = $get_section_name; |
| 1678 |
WooCommerceExport::$export_instance->data[$id]['course_id'] = $get_section_course_id; |
| 1679 |
} |
| 1680 |
|
| 1681 |
$get_question_title = ''; |
| 1682 |
$get_question_content = ''; |
| 1683 |
$get_question_mark = ''; |
| 1684 |
$get_question_explanation = ''; |
| 1685 |
$get_question_hint = ''; |
| 1686 |
$get_question_type = ''; |
| 1687 |
$get_option_value = ''; |
| 1688 |
|
| 1689 |
$get_question_ids = $wpdb->get_results("SELECT question_id FROM {$wpdb->prefix}learnpress_quiz_questions WHERE quiz_id = $id ", ARRAY_A); |
| 1690 |
foreach($get_question_ids as $question_ids){ |
| 1691 |
$question_id = $question_ids['question_id']; |
| 1692 |
$get_question_title .= $wpdb->get_var("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = $question_id ") . ','; |
| 1693 |
$get_question_content .= $wpdb->get_var("SELECT post_content FROM {$wpdb->prefix}posts WHERE ID = $question_id ") . ','; |
| 1694 |
|
| 1695 |
$get_question_mark .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $question_id AND meta_key = '_lp_mark' ") . ', '; |
| 1696 |
$get_question_explanation .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $question_id AND meta_key = '_lp_explanation' ") . ','; |
| 1697 |
$get_question_hint .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $question_id AND meta_key = '_lp_hint' ") . ','; |
| 1698 |
$get_question_type .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $question_id AND meta_key = '_lp_type' ") . ','; |
| 1699 |
|
| 1700 |
$get_question_options = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}learnpress_question_answers WHERE question_id = $question_id ", ARRAY_A); |
| 1701 |
$option_value = ''; |
| 1702 |
foreach($get_question_options as $question_option){ |
| 1703 |
if(empty($question_option['is_true'])){ |
| 1704 |
$question_option['is_true'] = 'no'; |
| 1705 |
} |
| 1706 |
|
| 1707 |
$option_value .= $question_option['title'] .'|'. $question_option['is_true'] . '->'; |
| 1708 |
} |
| 1709 |
$get_option_value .= rtrim($option_value, '->') . ','; |
| 1710 |
} |
| 1711 |
|
| 1712 |
WooCommerceExport::$export_instance->data[$id]['question_title'] = rtrim($get_question_title, ','); |
| 1713 |
WooCommerceExport::$export_instance->data[$id]['question_description'] = rtrim($get_question_content, ','); |
| 1714 |
WooCommerceExport::$export_instance->data[$id]['_lp_mark'] = rtrim($get_question_mark, ', '); |
| 1715 |
WooCommerceExport::$export_instance->data[$id]['_lp_explanation'] = rtrim($get_question_explanation, ','); |
| 1716 |
WooCommerceExport::$export_instance->data[$id]['_lp_hint'] = rtrim($get_question_hint, ','); |
| 1717 |
WooCommerceExport::$export_instance->data[$id]['_lp_type'] = rtrim($get_question_type, ','); |
| 1718 |
WooCommerceExport::$export_instance->data[$id]['question_options'] = rtrim($get_option_value, ','); |
| 1719 |
|
| 1720 |
} |
| 1721 |
|
| 1722 |
public function getQuestionData($id){ |
| 1723 |
global $wpdb; |
| 1724 |
$get_quiz_id = $wpdb->get_var("SELECT quiz_id FROM {$wpdb->prefix}learnpress_quiz_questions WHERE question_id = $id "); |
| 1725 |
|
| 1726 |
$get_question_options = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}learnpress_question_answers WHERE question_id = $id ", ARRAY_A); |
| 1727 |
$option_value = ''; |
| 1728 |
foreach($get_question_options as $question_options){ |
| 1729 |
if(empty($question_options['is_true'])){ |
| 1730 |
$question_options['is_true'] = 'no'; |
| 1731 |
} |
| 1732 |
$option_value .= $question_options['title'] .'|'. $question_options['is_true'] . '->'; |
| 1733 |
} |
| 1734 |
|
| 1735 |
if(!empty($get_quiz_id)){ |
| 1736 |
$get_section_id = $wpdb->get_var("SELECT section_id FROM {$wpdb->prefix}learnpress_section_items WHERE item_id = $get_quiz_id AND item_type = 'lp_quiz' "); |
| 1737 |
if(!empty($get_section_id)){ |
| 1738 |
$get_section_name = $wpdb->get_var("SELECT section_name FROM {$wpdb->prefix}learnpress_sections WHERE section_id = $get_section_id "); |
| 1739 |
$get_section_course_id = $wpdb->get_var("SELECT section_course_id FROM {$wpdb->prefix}learnpress_sections WHERE section_id = $get_section_id "); |
| 1740 |
|
| 1741 |
WooCommerceExport::$export_instance->data[$id]['curriculum_name'] = $get_section_name; |
| 1742 |
WooCommerceExport::$export_instance->data[$id]['course_id'] = $get_section_course_id; |
| 1743 |
} |
| 1744 |
WooCommerceExport::$export_instance->data[$id]['quiz_id'] = $get_quiz_id; |
| 1745 |
} |
| 1746 |
|
| 1747 |
WooCommerceExport::$export_instance->data[$id]['question_options'] = rtrim($option_value, '->'); |
| 1748 |
} |
| 1749 |
|
| 1750 |
public function getOrderData($id){ |
| 1751 |
global $wpdb; |
| 1752 |
|
| 1753 |
$order_status = $wpdb->get_var("SELECT post_status FROM {$wpdb->prefix}posts WHERE ID = $id "); |
| 1754 |
$order_date = $wpdb->get_var("SELECT post_date FROM {$wpdb->prefix}posts WHERE ID = $id "); |
| 1755 |
$order_total = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id AND meta_key = '_order_total' "); |
| 1756 |
$order_subtotal = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id AND meta_key = '_order_subtotal' "); |
| 1757 |
$user_id = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id AND meta_key = '_user_id' "); |
| 1758 |
|
| 1759 |
$get_order_items = $wpdb->get_results("SELECT order_item_id FROM {$wpdb->prefix}learnpress_order_items WHERE order_id = $id ",ARRAY_A); |
| 1760 |
$course_id = ''; |
| 1761 |
$item_quantity = ''; |
| 1762 |
$item_total = ''; |
| 1763 |
$item_subtotal = ''; |
| 1764 |
foreach($get_order_items as $get_order_values){ |
| 1765 |
$order_item_id = $get_order_values['order_item_id']; |
| 1766 |
|
| 1767 |
$course_id .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}learnpress_order_itemmeta WHERE learnpress_order_item_id = $order_item_id AND meta_key = '_course_id' ") . ', '; |
| 1768 |
$item_quantity .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}learnpress_order_itemmeta WHERE learnpress_order_item_id = $order_item_id AND meta_key = '_quantity' ") . ', '; |
| 1769 |
$item_total .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}learnpress_order_itemmeta WHERE learnpress_order_item_id = $order_item_id AND meta_key = '_subtotal' ") . ', '; |
| 1770 |
$item_subtotal .= $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}learnpress_order_itemmeta WHERE learnpress_order_item_id = $order_item_id AND meta_key = '_total' ") . ', '; |
| 1771 |
} |
| 1772 |
|
| 1773 |
WooCommerceExport::$export_instance->data[$id]['order_status'] = $order_status; |
| 1774 |
WooCommerceExport::$export_instance->data[$id]['order_date'] = $order_date; |
| 1775 |
WooCommerceExport::$export_instance->data[$id]['_order_total'] = $order_total; |
| 1776 |
WooCommerceExport::$export_instance->data[$id]['_order_subtotal'] = $order_subtotal; |
| 1777 |
WooCommerceExport::$export_instance->data[$id]['user_id'] = $user_id; |
| 1778 |
WooCommerceExport::$export_instance->data[$id]['item_id'] = rtrim($course_id, ', '); |
| 1779 |
WooCommerceExport::$export_instance->data[$id]['item_quantity'] = rtrim($item_quantity, ', '); |
| 1780 |
WooCommerceExport::$export_instance->data[$id]['_item_total'] = rtrim($item_total, ', '); |
| 1781 |
WooCommerceExport::$export_instance->data[$id]['_item_subtotal'] = rtrim($item_subtotal, ', '); |
| 1782 |
} |
| 1783 |
|
| 1784 |
public function elementor_export($id){ |
| 1785 |
$elementorExport = new ElementorExport; |
| 1786 |
$variable= $elementorExport->templateExport(); |
| 1787 |
if(!empty($variable)){ |
| 1788 |
foreach($variable as $key=>$value){ |
| 1789 |
if ($value['ID'] == $id) { |
| 1790 |
WooCommerceExport::$export_instance->data[$id]['ID'] = $id; |
| 1791 |
WooCommerceExport::$export_instance->data[$id]['Template title'] = $value['Template title']; |
| 1792 |
WooCommerceExport::$export_instance->data[$id]['Template content'] = $value['Template content']; |
| 1793 |
WooCommerceExport::$export_instance->data[$id]['Style'] = $value['Style']; |
| 1794 |
WooCommerceExport::$export_instance->data[$id]['Template type'] = $value['Template type']; |
| 1795 |
WooCommerceExport::$export_instance->data[$id]['Created time'] = $value['Created time']; |
| 1796 |
WooCommerceExport::$export_instance->data[$id]['Created by'] = $value['Created by']; |
| 1797 |
WooCommerceExport::$export_instance->data[$id]['Template status'] = $value['Template status']; |
| 1798 |
WooCommerceExport::$export_instance->data[$id]['Category'] = $value['Category']; |
| 1799 |
} |
| 1800 |
} |
| 1801 |
} |
| 1802 |
} |
| 1803 |
|
| 1804 |
public function getCourseDataMasterLMS($id) { |
| 1805 |
global $wpdb; |
| 1806 |
|
| 1807 |
$get_item_details = $wpdb->get_results("SELECT item_id, item_title |
| 1808 |
FROM {$wpdb->prefix}stm_lms_curriculum_log WHERE course_id = $id", ARRAY_A); |
| 1809 |
|
| 1810 |
|
| 1811 |
$curicullam = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='curriculum' "); |
| 1812 |
$curicullam_array = explode(',', $curicullam); |
| 1813 |
foreach ($curicullam_array as &$value) { |
| 1814 |
if (ctype_digit($value)) { |
| 1815 |
$value = ''; |
| 1816 |
} |
| 1817 |
} |
| 1818 |
$curicullam = implode(',', $curicullam_array); |
| 1819 |
$curicullam = trim($curicullam, ','); |
| 1820 |
$curicullam_withoutId = preg_replace('/,{2,}/', ',', $curicullam); |
| 1821 |
|
| 1822 |
$faq = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='faq' "); |
| 1823 |
$faq_array = json_decode($faq, true); |
| 1824 |
$faq_output = ''; |
| 1825 |
foreach ($faq_array as $faq_item) { |
| 1826 |
$faq_output .= 'question:' . $faq_item['question'] . ',answer:' . $faq_item['answer'] . ' | '; |
| 1827 |
} |
| 1828 |
$faq_output = rtrim($faq_output, ' | '); |
| 1829 |
|
| 1830 |
|
| 1831 |
$course_files_pack = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='course_files_pack' "); |
| 1832 |
$course_files_pack_array = json_decode($course_files_pack, true); |
| 1833 |
$course_files_pack_output = ''; |
| 1834 |
foreach ($course_files_pack_array as $course_files_pack_item) { |
| 1835 |
$course_files_pack_output .= 'course_files_label:' . $course_files_pack_item['course_files_label']; |
| 1836 |
} |
| 1837 |
$status_dates = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='status_dates' "); |
| 1838 |
$status_dates_start = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='status_dates_start' "); |
| 1839 |
$views = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='views'"); |
| 1840 |
$duration_info = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='duration_info'"); |
| 1841 |
$featured = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='featured'"); |
| 1842 |
$level = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='level'"); |
| 1843 |
$current_students = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='current_students'"); |
| 1844 |
$video_duration = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='video_duration'"); |
| 1845 |
$price = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='price'"); |
| 1846 |
$sale_price = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='sale_price'"); |
| 1847 |
$status = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='status'"); |
| 1848 |
$expiration_course = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='expiration_course'"); |
| 1849 |
$not_membership = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='not_membership'"); |
| 1850 |
$end_time = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='end_time'"); |
| 1851 |
$announcement = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='announcement'"); |
| 1852 |
$course_files_pack = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='course_files_pack'"); |
| 1853 |
$status_dates_end = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='status_dates_end' "); |
| 1854 |
$status_dates_start = date('Y-m-d', $status_dates_start/1000); |
| 1855 |
$status_dates_end = date('Y-m-d', $status_dates_end/1000); |
| 1856 |
$status_dates_array = explode(',', $status_dates); |
| 1857 |
$status_dates_formatted = array(); |
| 1858 |
|
| 1859 |
foreach ($status_dates_array as $date) { |
| 1860 |
$status_dates_formatted[] = date('Y-m-d', $date/1000); |
| 1861 |
} |
| 1862 |
|
| 1863 |
$status_dates_formatted_str = implode(',', $status_dates_formatted); |
| 1864 |
|
| 1865 |
$get_lesson_id = ''; |
| 1866 |
$get_lesson_name = ''; |
| 1867 |
$get_quiz_id = ''; |
| 1868 |
$get_quiz_name = ''; |
| 1869 |
|
| 1870 |
foreach ($get_item_details as $item_details) { |
| 1871 |
$item_id = $item_details['item_id']; |
| 1872 |
|
| 1873 |
$lesson_id = ''; |
| 1874 |
$lesson_name = ''; |
| 1875 |
$quiz_id = ''; |
| 1876 |
$quiz_name = ''; |
| 1877 |
|
| 1878 |
$get_section_item_details = $wpdb->get_results("SELECT distinct item_id, item_type FROM {$wpdb->prefix}stm_lms_curriculum_log WHERE item_id = $item_id ", ARRAY_A); |
| 1879 |
|
| 1880 |
foreach ($get_section_item_details as $section_item_details) { |
| 1881 |
if ($section_item_details['item_type'] == 'stm-lessons') { |
| 1882 |
$lesson_id .= $item_id . ', '; |
| 1883 |
$lesson_name .= $wpdb->get_var("SELECT distinct post_title FROM {$wpdb->prefix}posts WHERE ID = $item_id ") . ','; |
| 1884 |
} else if ($section_item_details['item_type'] == 'stm-quizzes') { |
| 1885 |
$quiz_id .= $item_id . ', '; |
| 1886 |
$quiz_name .= $wpdb->get_var("SELECT distinct post_title FROM {$wpdb->prefix}posts WHERE ID = $item_id ") . ','; |
| 1887 |
} |
| 1888 |
} |
| 1889 |
|
| 1890 |
$get_lesson_id .= rtrim($lesson_id, ', ') . '|'; |
| 1891 |
$get_lesson_name .= rtrim($lesson_name, ',') . '|'; |
| 1892 |
$get_quiz_id .= rtrim($quiz_id, ', ') . '|'; |
| 1893 |
$get_quiz_name .= rtrim($quiz_name, ',') . '|'; |
| 1894 |
|
| 1895 |
$get_lesson_id = str_replace('||', '|', $get_lesson_id); |
| 1896 |
$get_lesson_name = str_replace('||', '|', $get_lesson_name); |
| 1897 |
$get_quiz_id = str_replace('||', '|', $get_quiz_id); |
| 1898 |
$get_quiz_name = str_replace('||', '|', $get_quiz_name); |
| 1899 |
} |
| 1900 |
|
| 1901 |
WooCommerceExport::$export_instance->data[$id]['lesson_id'] = $get_lesson_id; |
| 1902 |
WooCommerceExport::$export_instance->data[$id]['lesson_name'] = $get_lesson_name; |
| 1903 |
WooCommerceExport::$export_instance->data[$id]['quiz_id'] = $get_quiz_id; |
| 1904 |
WooCommerceExport::$export_instance->data[$id]['quiz_name'] = $get_quiz_name; |
| 1905 |
WooCommerceExport::$export_instance->data[$id]['status_dates'] = $status_dates_formatted_str; |
| 1906 |
WooCommerceExport::$export_instance->data[$id]['status_dates_start'] = $status_dates_start; |
| 1907 |
WooCommerceExport::$export_instance->data[$id]['status_dates_end'] = $status_dates_end; |
| 1908 |
WooCommerceExport::$export_instance->data[$id]['curriculum'] = $curicullam_withoutId; |
| 1909 |
WooCommerceExport::$export_instance->data[$id]['video_duration'] = $video_duration; |
| 1910 |
WooCommerceExport::$export_instance->data[$id]['views'] = $views; |
| 1911 |
WooCommerceExport::$export_instance->data[$id]['price'] = $price; |
| 1912 |
WooCommerceExport::$export_instance->data[$id]['sale_price'] = $sale_price; |
| 1913 |
WooCommerceExport::$export_instance->data[$id]['status'] = $status; |
| 1914 |
WooCommerceExport::$export_instance->data[$id]['expiration_course'] = $expiration_course; |
| 1915 |
WooCommerceExport::$export_instance->data[$id]['not_membership'] = $not_membership; |
| 1916 |
WooCommerceExport::$export_instance->data[$id]['end_time'] = $end_time; |
| 1917 |
WooCommerceExport::$export_instance->data[$id]['announcement'] = $announcement; |
| 1918 |
WooCommerceExport::$export_instance->data[$id]['course_files_pack'] = $course_files_pack; |
| 1919 |
WooCommerceExport::$export_instance->data[$id]['duration_info'] = $duration_info; |
| 1920 |
WooCommerceExport::$export_instance->data[$id]['featured'] = $featured; |
| 1921 |
WooCommerceExport::$export_instance->data[$id]['level'] = $level; |
| 1922 |
WooCommerceExport::$export_instance->data[$id]['current_students'] = $current_students; |
| 1923 |
WooCommerceExport::$export_instance->data[$id]['faq'] = $faq_output; |
| 1924 |
WooCommerceExport::$export_instance->data[$id]['course_files_pack'] = $course_files_pack_output; |
| 1925 |
|
| 1926 |
} |
| 1927 |
|
| 1928 |
public function getQuestionDataMasterLMS($id) { |
| 1929 |
|
| 1930 |
global $wpdb; |
| 1931 |
$type = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='type' "); |
| 1932 |
$answers = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='answers' "); |
| 1933 |
$question_explanation = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='question_explanation' "); |
| 1934 |
$question = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='question' "); |
| 1935 |
$question_hint = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='question_hint' "); |
| 1936 |
$question_view_type = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='question_view_type' "); |
| 1937 |
$image = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='image' "); |
| 1938 |
$answers = unserialize($answers); |
| 1939 |
$answers_string = ''; |
| 1940 |
foreach ($answers as $answer) { |
| 1941 |
$answers_string .= $answer['text'] . ',' . $answer['isTrue'] . '|'; |
| 1942 |
} |
| 1943 |
|
| 1944 |
WooCommerceExport::$export_instance->data[$id]['type'] = $type; |
| 1945 |
WooCommerceExport::$export_instance->data[$id]['answers'] = rtrim($answers_string); |
| 1946 |
WooCommerceExport::$export_instance->data[$id]['question_explanation'] = $question_explanation; |
| 1947 |
WooCommerceExport::$export_instance->data[$id]['question'] = $question; |
| 1948 |
WooCommerceExport::$export_instance->data[$id]['question_hint'] = $question_hint; |
| 1949 |
WooCommerceExport::$export_instance->data[$id]['question_view_type'] = $question_view_type; |
| 1950 |
WooCommerceExport::$export_instance->data[$id]['image'] = $image; |
| 1951 |
} |
| 1952 |
public function orderDataMasterLMS($id) { |
| 1953 |
global $wpdb; |
| 1954 |
$status = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='status' "); |
| 1955 |
|
| 1956 |
WooCommerceExport::$export_instance->data[$id]['status'] = $status; |
| 1957 |
} |
| 1958 |
public function quizzDataMasterLMS($id) { |
| 1959 |
global $wpdb; |
| 1960 |
$duration = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='duration' "); |
| 1961 |
$thumbnail_id = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='thumbnail_id' "); |
| 1962 |
$lesson_excerpt = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_excerpt' "); |
| 1963 |
$quiz_style = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='quiz_style' "); |
| 1964 |
$correct_answer = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='correct_answer' "); |
| 1965 |
$passing_grade = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='passing_grade' "); |
| 1966 |
$re_take_cut = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='re_take_cut' "); |
| 1967 |
$random_questions = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='random_questions' "); |
| 1968 |
$questions = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='questions' "); |
| 1969 |
|
| 1970 |
WooCommerceExport::$export_instance->data[$id]['duration'] = $duration; |
| 1971 |
WooCommerceExport::$export_instance->data[$id]['thumbnail_id'] = $thumbnail_id; |
| 1972 |
WooCommerceExport::$export_instance->data[$id]['lesson_excerpt'] = $lesson_excerpt; |
| 1973 |
WooCommerceExport::$export_instance->data[$id]['quiz_style'] = $quiz_style; |
| 1974 |
WooCommerceExport::$export_instance->data[$id]['correct_answer'] = $correct_answer; |
| 1975 |
WooCommerceExport::$export_instance->data[$id]['passing_grade'] = $passing_grade; |
| 1976 |
WooCommerceExport::$export_instance->data[$id]['re_take_cut'] = $re_take_cut; |
| 1977 |
WooCommerceExport::$export_instance->data[$id]['random_questions'] = $random_questions; |
| 1978 |
WooCommerceExport::$export_instance->data[$id]['questions'] = $questions; |
| 1979 |
} |
| 1980 |
|
| 1981 |
public function getLessonDataMasterLMS($id) |
| 1982 |
{ |
| 1983 |
global $wpdb; |
| 1984 |
$type = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='type'"); |
| 1985 |
$duration = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='duration' "); |
| 1986 |
$preview = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='preview' "); |
| 1987 |
$lesson_excerpt = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_excerpt' "); |
| 1988 |
$_thumbnail_id = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='_thumbnail_id' "); |
| 1989 |
$video_type = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='video_type' "); |
| 1990 |
$lesson_youtube_url = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_youtube_url' "); |
| 1991 |
$presto_player_idx = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='presto_player_idx' "); |
| 1992 |
$lesson_video = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_video' "); |
| 1993 |
$lesson_video_poster = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_video_poster' "); |
| 1994 |
$lesson_video_width = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_video_width' "); |
| 1995 |
$lesson_shortcode = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_shortcode' "); |
| 1996 |
$lesson_embed_ctx = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_embed_ctx' "); |
| 1997 |
$lesson_stream_url = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_stream_url' "); |
| 1998 |
$lesson_vimeo_url = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_vimeo_url' "); |
| 1999 |
$lesson_ext_link_url = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_ext_link_url' "); |
| 2000 |
$lesson_files_pack = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $id and meta_key='lesson_files_pack' "); |
| 2001 |
|
| 2002 |
$lesson_files_pack_array = json_decode($lesson_files_pack, true); |
| 2003 |
$lesson_files_pack_output = ''; |
| 2004 |
foreach ($lesson_files_pack_array as $lesson_files_pack_item) { |
| 2005 |
if (!empty($lesson_files_pack_item['closed_tab'])) { |
| 2006 |
$lesson_files_pack_output .= 'closed_tab:' . $lesson_files_pack_item['closed_tab'] . ','; |
| 2007 |
} |
| 2008 |
$lesson_files_pack_output .= 'lesson_files_label:' . $lesson_files_pack_item['lesson_files_label'] . ','; |
| 2009 |
$lesson_files_pack_output = rtrim($lesson_files_pack_output, ','); } |
| 2010 |
|
| 2011 |
WooCommerceExport::$export_instance->data[$id]['type'] = $type; |
| 2012 |
WooCommerceExport::$export_instance->data[$id]['duration'] = $duration; |
| 2013 |
WooCommerceExport::$export_instance->data[$id]['preview'] = $preview; |
| 2014 |
WooCommerceExport::$export_instance->data[$id]['lesson_excerpt'] = $lesson_excerpt; |
| 2015 |
WooCommerceExport::$export_instance->data[$id]['_thumbnail_id'] = $_thumbnail_id; |
| 2016 |
WooCommerceExport::$export_instance->data[$id]['video_type'] = $video_type; |
| 2017 |
WooCommerceExport::$export_instance->data[$id]['lesson_youtube_url'] = $lesson_youtube_url; |
| 2018 |
WooCommerceExport::$export_instance->data[$id]['presto_player_idx'] = $presto_player_idx; |
| 2019 |
WooCommerceExport::$export_instance->data[$id]['lesson_video'] = $lesson_video; |
| 2020 |
WooCommerceExport::$export_instance->data[$id]['lesson_video_poster'] = $lesson_video_poster; |
| 2021 |
WooCommerceExport::$export_instance->data[$id]['lesson_video_width'] = $lesson_video_width; |
| 2022 |
WooCommerceExport::$export_instance->data[$id]['lesson_shortcode'] = $lesson_shortcode; |
| 2023 |
WooCommerceExport::$export_instance->data[$id]['lesson_embed_ctx'] = $lesson_embed_ctx; |
| 2024 |
WooCommerceExport::$export_instance->data[$id]['lesson_stream_url'] = $lesson_stream_url; |
| 2025 |
WooCommerceExport::$export_instance->data[$id]['lesson_vimeo_url'] = $lesson_vimeo_url; |
| 2026 |
WooCommerceExport::$export_instance->data[$id]['lesson_ext_link_url'] = $lesson_ext_link_url; |
| 2027 |
WooCommerceExport::$export_instance->data[$id]['lesson_files_pack'] = $lesson_files_pack_output; |
| 2028 |
} |
| 2029 |
|
| 2030 |
|
| 2031 |
public function getMenuData($term_id){ |
| 2032 |
global $wpdb; |
| 2033 |
$term_name = get_term( $term_id )->name; |
| 2034 |
$get_object_ids = $wpdb->get_results("SELECT p.* FROM {$wpdb->prefix}posts AS p |
| 2035 |
LEFT JOIN {$wpdb->prefix}term_relationships AS tr ON tr.object_id = p.ID |
| 2036 |
LEFT JOIN {$wpdb->prefix}term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id |
| 2037 |
WHERE p.post_type = 'nav_menu_item' |
| 2038 |
AND tt.term_id = $term_id ", ARRAY_A); |
| 2039 |
|
| 2040 |
$menu_item_types = ''; |
| 2041 |
$menu_object_ids = ''; |
| 2042 |
$menu_objects = ''; |
| 2043 |
$menu_urls = ''; |
| 2044 |
foreach($get_object_ids as $object_ids){ |
| 2045 |
$object_id = $object_ids['ID']; |
| 2046 |
|
| 2047 |
$get_object_meta = $wpdb->get_results("SELECT meta_key , meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = $object_id", ARRAY_A); |
| 2048 |
$object_meta_key = array_column($get_object_meta, 'meta_key'); |
| 2049 |
$object_meta_value = array_column($get_object_meta, 'meta_value'); |
| 2050 |
$object_array = array_combine($object_meta_key, $object_meta_value); |
| 2051 |
|
| 2052 |
$menu_item_type = $object_array['_menu_item_type']; |
| 2053 |
$menu_item_object = $object_array['_menu_item_object']; |
| 2054 |
$menu_object_item_id = $object_array['_menu_item_object_id']; |
| 2055 |
|
| 2056 |
if(($menu_item_type == 'post_type') && ($menu_item_object == 'post' || $menu_item_object == 'page')){ |
| 2057 |
$menu_object_item_title = $wpdb->get_var("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = $menu_object_item_id AND post_type = '$menu_item_object' "); |
| 2058 |
} |
| 2059 |
elseif($menu_item_type == 'custom' && $menu_item_object == 'custom'){ |
| 2060 |
$menu_object_item_title = $wpdb->get_var("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = $menu_object_item_id AND post_type = 'nav_menu_item' "); |
| 2061 |
} |
| 2062 |
elseif($menu_item_type == 'taxonomy'){ |
| 2063 |
$category_data = get_term_by('id', $menu_object_item_id, $menu_item_object); |
| 2064 |
$menu_object_item_title = $category_data->name; |
| 2065 |
} |
| 2066 |
else{ |
| 2067 |
$menu_object_item_title = $menu_object_item_id; |
| 2068 |
} |
| 2069 |
|
| 2070 |
$menu_item_types .= $menu_item_type . ','; |
| 2071 |
$menu_object_ids .= $menu_object_item_title . ','; |
| 2072 |
$menu_objects .= $menu_item_object . ','; |
| 2073 |
$menu_urls .= $object_array['_menu_item_url'] . ','; |
| 2074 |
} |
| 2075 |
|
| 2076 |
WooCommerceExport::$export_instance->data[$term_id]['menu_title'] = $term_name; |
| 2077 |
WooCommerceExport::$export_instance->data[$term_id]['_menu_item_type'] = rtrim($menu_item_types, ','); |
| 2078 |
WooCommerceExport::$export_instance->data[$term_id]['_menu_item_object_id'] = rtrim($menu_object_ids, ','); |
| 2079 |
WooCommerceExport::$export_instance->data[$term_id]['_menu_item_object'] = rtrim($menu_objects, ','); |
| 2080 |
WooCommerceExport::$export_instance->data[$term_id]['_menu_item_url'] = rtrim($menu_urls, ','); |
| 2081 |
|
| 2082 |
$get_nav_options = get_option("nav_menu_options"); |
| 2083 |
if(!empty($get_nav_options['auto_add'])){ |
| 2084 |
if(in_array($term_id, $get_nav_options['auto_add'])){ |
| 2085 |
WooCommerceExport::$export_instance->data[$term_id]['menu_auto_add'] = 'yes'; |
| 2086 |
}else{ |
| 2087 |
WooCommerceExport::$export_instance->data[$term_id]['menu_auto_add'] = 'no'; |
| 2088 |
} |
| 2089 |
} |
| 2090 |
else{ |
| 2091 |
WooCommerceExport::$export_instance->data[$term_id]['menu_auto_add'] = 'no'; |
| 2092 |
} |
| 2093 |
|
| 2094 |
$get_navigation_locations = get_nav_menu_locations(); |
| 2095 |
foreach($get_navigation_locations as $nav_keys => $nav_values){ |
| 2096 |
if($nav_values == $term_id){ |
| 2097 |
WooCommerceExport::$export_instance->data[$term_id][$nav_keys] = 'yes'; |
| 2098 |
}else{ |
| 2099 |
WooCommerceExport::$export_instance->data[$term_id][$nav_keys] = 'no'; |
| 2100 |
} |
| 2101 |
} |
| 2102 |
} |
| 2103 |
|
| 2104 |
} |
| 2105 |
|
| 2106 |
global $woocom_exp_class; |
| 2107 |
$woocom_exp_class = WooCommerceExport::getInstance(); |
| 2108 |
|