| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* E2Pdf WooCommerce Extension |
| 5 |
* @copyright Copyright 2017 https://e2pdf.com |
| 6 |
* @license GPLv3 |
| 7 |
* @version 1 |
| 8 |
* @link https://e2pdf.com |
| 9 |
* @since 1.09.07 |
| 10 |
*/ |
| 11 |
if (!defined('ABSPATH')) { |
| 12 |
die('Access denied.'); |
| 13 |
} |
| 14 |
|
| 15 |
class Extension_E2pdf_Woocommerce extends Model_E2pdf_Model { |
| 16 |
|
| 17 |
private $options; |
| 18 |
private $info = array( |
| 19 |
'key' => 'woocommerce', |
| 20 |
'title' => 'WooCommerce', |
| 21 |
); |
| 22 |
|
| 23 |
/** |
| 24 |
* Get info about extension |
| 25 |
* @param string $key - Key to get assigned extension info value |
| 26 |
* @return array|string - Extension Key and Title or Assigned extension info value |
| 27 |
*/ |
| 28 |
public function info($key = false) { |
| 29 |
if ($key && isset($this->info[$key])) { |
| 30 |
return $this->info[$key]; |
| 31 |
} else { |
| 32 |
return array( |
| 33 |
$this->info['key'] => $this->info['title'], |
| 34 |
); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Check if needed plugin active |
| 40 |
* @return bool - Activated/Not Activated plugin |
| 41 |
*/ |
| 42 |
public function active() { |
| 43 |
if (defined('E2PDF_WOOCOMMERCE_EXTENSION') || $this->helper->load('extension')->is_plugin_active('woocommerce/woocommerce.php')) { |
| 44 |
return true; |
| 45 |
} |
| 46 |
return false; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Set option |
| 51 |
* @param string $key - Key of option |
| 52 |
* @param string $value - Value of option |
| 53 |
* @return bool - Status of setting option |
| 54 |
*/ |
| 55 |
public function set($key, $value) { |
| 56 |
if (!isset($this->options)) { |
| 57 |
$this->options = new stdClass(); |
| 58 |
} |
| 59 |
$this->options->$key = $value; |
| 60 |
switch ($key) { |
| 61 |
case 'dataset': |
| 62 |
$this->set('cached_post', false); |
| 63 |
if ($this->get('dataset')) { |
| 64 |
$this->set('cached_post', get_post($this->get('dataset'))); |
| 65 |
} |
| 66 |
break; |
| 67 |
default: |
| 68 |
break; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Get option by key |
| 74 |
* @param string $key - Key to get assigned option value |
| 75 |
* @return mixed |
| 76 |
*/ |
| 77 |
public function get($key) { |
| 78 |
if (isset($this->options->$key)) { |
| 79 |
$value = $this->options->$key; |
| 80 |
} else { |
| 81 |
switch ($key) { |
| 82 |
case 'args': |
| 83 |
$value = array(); |
| 84 |
break; |
| 85 |
default: |
| 86 |
$value = false; |
| 87 |
break; |
| 88 |
} |
| 89 |
} |
| 90 |
return $value; |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* Get items to work with |
| 95 |
* @return array() - List of available items |
| 96 |
*/ |
| 97 |
public function items() { |
| 98 |
$items = array(); |
| 99 |
$forms = array( |
| 100 |
'product', |
| 101 |
'product_variation', |
| 102 |
'shop_order', |
| 103 |
'shop_subscription', |
| 104 |
'cart', |
| 105 |
); |
| 106 |
foreach ($forms as $form) { |
| 107 |
$item = $this->item($form); |
| 108 |
if (!empty($item->id)) { |
| 109 |
$items[] = $this->item($form); |
| 110 |
} |
| 111 |
} |
| 112 |
return $items; |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Get entries for export |
| 117 |
* @param string $item_id - Item ID |
| 118 |
* @param string $name - Entries names |
| 119 |
* @return array() - Entries list |
| 120 |
*/ |
| 121 |
public function datasets($item_id = false, $name = false) { |
| 122 |
$datasets = array(); |
| 123 |
$entries = array(); |
| 124 |
if ($item_id) { |
| 125 |
if ($item_id == 'cart') { |
| 126 |
if (function_exists('wc_get_page_id') && wc_get_page_id('cart')) { |
| 127 |
$entries = get_posts( |
| 128 |
array( |
| 129 |
'post_type' => 'any', |
| 130 |
'post__in' => array(wc_get_page_id('cart')), |
| 131 |
'numberposts' => -1, |
| 132 |
'post_status' => 'any', |
| 133 |
) |
| 134 |
); |
| 135 |
} |
| 136 |
} elseif ($item_id == 'shop_order' && get_option('woocommerce_custom_orders_table_enabled') === 'yes' && get_option('woocommerce_custom_orders_table_data_sync_enabled') !== 'yes') { |
| 137 |
$entries = get_posts( |
| 138 |
array( |
| 139 |
'post_type' => 'shop_order_placehold', |
| 140 |
'numberposts' => -1, |
| 141 |
'post_status' => 'any', |
| 142 |
) |
| 143 |
); |
| 144 |
} else { |
| 145 |
$entries = get_posts( |
| 146 |
array( |
| 147 |
'post_type' => $item_id, |
| 148 |
'numberposts' => -1, |
| 149 |
'post_status' => 'any', |
| 150 |
) |
| 151 |
); |
| 152 |
} |
| 153 |
if ($entries) { |
| 154 |
$this->set('item', $item_id); |
| 155 |
foreach ($entries as $key => $entry) { |
| 156 |
$this->set('dataset', $entry->ID); |
| 157 |
$entry_title = $this->render($name); |
| 158 |
if (!$entry_title) { |
| 159 |
$entry_title = isset($entry->post_title) && $entry->post_title ? $entry->post_title : $entry->ID; |
| 160 |
} |
| 161 |
$datasets[] = array( |
| 162 |
'key' => $entry->ID, |
| 163 |
'value' => $entry_title, |
| 164 |
); |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
return $datasets; |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Get item |
| 173 |
* @param string $item_id - Item ID |
| 174 |
* @return object - Item |
| 175 |
*/ |
| 176 |
public function item($item_id = false) { |
| 177 |
if (!$item_id && $this->get('item')) { |
| 178 |
$item_id = $this->get('item'); |
| 179 |
} |
| 180 |
$item = new stdClass(); |
| 181 |
$form = get_post_type_object($item_id); |
| 182 |
if ($form) { |
| 183 |
$item->id = $item_id; |
| 184 |
$item->name = $form->label ? $form->label : $item_id; |
| 185 |
$item->url = $this->helper->get_url(array('post_type' => $item_id), 'edit.php?'); |
| 186 |
} elseif ($item_id == 'cart' && function_exists('wc_get_page_id')) { |
| 187 |
$item->id = $item_id; |
| 188 |
$item->name = __('Cart / Checkout', 'e2pdf'); |
| 189 |
$item->url = $this->helper->get_url( |
| 190 |
array( |
| 191 |
'post' => wc_get_page_id('cart'), |
| 192 |
'action' => 'edit', |
| 193 |
), 'post.php?' |
| 194 |
); |
| 195 |
} else { |
| 196 |
$item->id = ''; |
| 197 |
$item->name = ''; |
| 198 |
$item->url = ''; |
| 199 |
} |
| 200 |
return $item; |
| 201 |
} |
| 202 |
|
| 203 |
/** |
| 204 |
* Get Dataset Actions |
| 205 |
* @param int $dataset_id - Dataset ID |
| 206 |
* @return object |
| 207 |
*/ |
| 208 |
public function get_dataset_actions($dataset_id = false) { |
| 209 |
$dataset_id = (int) $dataset_id; |
| 210 |
if (!$dataset_id) { |
| 211 |
return false; |
| 212 |
} |
| 213 |
$actions = new stdClass(); |
| 214 |
$actions->view = $this->helper->get_url( |
| 215 |
array( |
| 216 |
'post' => $dataset_id, |
| 217 |
'action' => 'edit', |
| 218 |
), 'post.php?' |
| 219 |
); |
| 220 |
$actions->delete = false; |
| 221 |
return $actions; |
| 222 |
} |
| 223 |
|
| 224 |
/** |
| 225 |
* Get Template Actions |
| 226 |
* @param int $template - Template ID |
| 227 |
* @return object |
| 228 |
*/ |
| 229 |
public function get_template_actions($template = false) { |
| 230 |
$template = (int) $template; |
| 231 |
if (!$template) { |
| 232 |
return; |
| 233 |
} |
| 234 |
$actions = new stdClass(); |
| 235 |
$actions->delete = false; |
| 236 |
return $actions; |
| 237 |
} |
| 238 |
|
| 239 |
public function load_actions() { |
| 240 |
$email_actions = apply_filters( |
| 241 |
'woocommerce_email_actions', |
| 242 |
array( |
| 243 |
'woocommerce_low_stock', |
| 244 |
'woocommerce_no_stock', |
| 245 |
'woocommerce_product_on_backorder', |
| 246 |
'woocommerce_order_status_pending_to_processing', |
| 247 |
'woocommerce_order_status_pending_to_completed', |
| 248 |
'woocommerce_order_status_processing_to_cancelled', |
| 249 |
'woocommerce_order_status_pending_to_failed', |
| 250 |
'woocommerce_order_status_pending_to_on-hold', |
| 251 |
'woocommerce_order_status_failed_to_processing', |
| 252 |
'woocommerce_order_status_failed_to_completed', |
| 253 |
'woocommerce_order_status_failed_to_on-hold', |
| 254 |
'woocommerce_order_status_cancelled_to_processing', |
| 255 |
'woocommerce_order_status_cancelled_to_completed', |
| 256 |
'woocommerce_order_status_cancelled_to_on-hold', |
| 257 |
'woocommerce_order_status_on-hold_to_processing', |
| 258 |
'woocommerce_order_status_on-hold_to_cancelled', |
| 259 |
'woocommerce_order_status_on-hold_to_failed', |
| 260 |
'woocommerce_order_status_completed', |
| 261 |
'woocommerce_order_fully_refunded', |
| 262 |
'woocommerce_order_partially_refunded', |
| 263 |
'woocommerce_new_customer_note', |
| 264 |
'woocommerce_created_customer', |
| 265 |
'ywgc_email_send_gift_card', |
| 266 |
) |
| 267 |
); |
| 268 |
|
| 269 |
foreach ($email_actions as $email_action) { |
| 270 |
add_action($email_action . '_notification', array($this, 'action_after_email'), 99); |
| 271 |
} |
| 272 |
add_action('woocommerce_after_resend_order_email', array($this, 'action_after_email'), 99); |
| 273 |
|
| 274 |
/* Compatibility fix with Enforcing Rules enabled */ |
| 275 |
add_action('woocommerce_settings_products', array($this, 'action_enforcing_rules_enabled_check'), -10); |
| 276 |
add_action('woocommerce_admin_process_product_object', array($this, 'action_enforcing_rules_enabled_check')); |
| 277 |
|
| 278 |
/* https://wordpress.org/plugins/elementor/ */ |
| 279 |
add_action('elementor/widget/before_render_content', array($this, 'action_elementor_widget_before_render_content')); |
| 280 |
add_action('elementor/frontend/widget/before_render', array($this, 'action_elementor_widget_before_render_content'), 5); |
| 281 |
|
| 282 |
/* https://wordpress.org/plugins/happy-elementor-addons/ compatibility fix */ |
| 283 |
add_action('elementor/frontend/before_render', array($this, 'action_elementor_widget_before_render_content'), 0); |
| 284 |
|
| 285 |
/* Temporary solution for File Downloads in WC Admin Order page */ |
| 286 |
add_action('add_meta_boxes_woocommerce_page_wc-orders', array($this, 'action_add_meta_boxes_woocommerce_page_wc_orders')); |
| 287 |
add_action('add_meta_boxes_shop_order', array($this, 'action_add_meta_boxes_woocommerce_page_wc_orders')); |
| 288 |
add_action('add_meta_boxes_shop_subscription', array($this, 'action_add_meta_boxes_woocommerce_page_wc_orders')); |
| 289 |
|
| 290 |
/* Order Hooks */ |
| 291 |
add_action('add_meta_boxes', array($this, 'hook_woocommerce_order_edit')); |
| 292 |
add_action('woocommerce_admin_order_actions_end', array($this, 'hook_woocommerce_order_row_actions')); |
| 293 |
add_action('woocommerce_order_details_before_order_table', array($this, 'hook_woocommerce_order_details')); |
| 294 |
add_action('woocommerce_order_details_before_order_table_items', array($this, 'hook_woocommerce_order_details')); |
| 295 |
add_action('woocommerce_order_details_after_order_table_items', array($this, 'hook_woocommerce_order_details')); |
| 296 |
add_action('woocommerce_order_details_after_order_table', array($this, 'hook_woocommerce_order_details')); |
| 297 |
add_action('woocommerce_after_order_details', array($this, 'hook_woocommerce_order_details')); |
| 298 |
add_action('woocommerce_proceed_to_checkout', array($this, 'hook_woocommerce_proceed_to_checkout')); |
| 299 |
add_action('woocommerce_review_order_before_submit', array($this, 'hook_woocommerce_review_order')); |
| 300 |
add_action('woocommerce_review_order_after_submit', array($this, 'hook_woocommerce_review_order')); |
| 301 |
|
| 302 |
/* Subscription Hooks */ |
| 303 |
add_action('add_meta_boxes', array($this, 'hook_woocommerce_subscription_edit')); |
| 304 |
add_action('woocommerce_subscription_before_actions', array($this, 'hook_woocommerce_subscription_details')); |
| 305 |
add_action('woocommerce_subscription_after_actions', array($this, 'hook_woocommerce_subscription_details')); |
| 306 |
add_action('wcs_subscription_details_table_before_dates', array($this, 'hook_woocommerce_subscription_details')); |
| 307 |
add_action('wcs_subscription_details_table_before_payment_method', array($this, 'hook_woocommerce_subscription_details')); |
| 308 |
add_action('wcs_subscription_details_table_after_dates', array($this, 'hook_woocommerce_subscription_details')); |
| 309 |
|
| 310 |
//phpcs:disable |
| 311 |
if (get_option('e2pdf_wc_cart_template_id', '0')) { |
| 312 |
add_action('woocommerce_proceed_to_checkout', array($this, 'action_e2pdf_wc_cart_template_id'), (int) get_option('e2pdf_wc_cart_template_id_priority', '10')); |
| 313 |
} |
| 314 |
if (get_option('e2pdf_wc_checkout_template_id', '0') && get_option('e2pdf_wc_checkout_template_id_hook', 'woocommerce_review_order_before_submit') && in_array(get_option('e2pdf_wc_checkout_template_id_hook', 'woocommerce_review_order_before_submit'), array('woocommerce_review_order_before_submit', 'woocommerce_review_order_after_submit'))) { |
| 315 |
add_action(get_option('e2pdf_wc_checkout_template_id_hook', 'woocommerce_review_order_before_submit'), array($this, 'action_e2pdf_wc_checkout_template_id'), (int) get_option('e2pdf_wc_checkout_template_id_priority', '10')); |
| 316 |
} |
| 317 |
if (get_option('e2pdf_wc_order_details_template_id', '0') && get_option('e2pdf_wc_order_details_template_id_hook', 'woocommerce_order_details_before_order_table') && in_array(get_option('e2pdf_wc_order_details_template_id_hook', 'woocommerce_order_details_before_order_table'), array('woocommerce_order_details_before_order_table', 'woocommerce_order_details_before_order_table_items', 'woocommerce_order_details_after_order_table_items', 'woocommerce_order_details_after_order_table', 'woocommerce_after_order_details'))) { |
| 318 |
add_action(get_option('e2pdf_wc_order_details_template_id_hook', 'woocommerce_order_details_before_order_table'), array($this, 'action_e2pdf_wc_order_details_template_id'), (int) get_option('e2pdf_wc_order_details_template_id_priority', '10')); |
| 319 |
} |
| 320 |
if (get_option('e2pdf_wc_admin_order_actions_template_id', '0') && get_option('e2pdf_wc_admin_order_actions_template_id_hook', 'woocommerce_admin_order_actions_end') && in_array(get_option('e2pdf_wc_admin_order_actions_template_id_hook', 'woocommerce_admin_order_actions_end'), array('woocommerce_admin_order_actions_start', 'woocommerce_admin_order_actions_end'))) { |
| 321 |
add_action(get_option('e2pdf_wc_admin_order_actions_template_id_hook', 'woocommerce_admin_order_actions_end'), array($this, 'action_e2pdf_wc_admin_order_actions_template_id'), (int) get_option('e2pdf_wc_admin_order_actions_template_id_priority', '10')); |
| 322 |
} |
| 323 |
if (get_option('e2pdf_wc_admin_order_details_template_id', '0')) { |
| 324 |
add_action('add_meta_boxes', array($this, 'action_add_meta_boxes')); |
| 325 |
} |
| 326 |
//phpcs:enable |
| 327 |
} |
| 328 |
|
| 329 |
public function load_filters() { |
| 330 |
add_filter('woocommerce_product_file_download_path', array($this, 'filter_woocommerce_product_file_download_path'), 10, 3); |
| 331 |
add_filter('woocommerce_short_description', array($this, 'filter_content_custom')); |
| 332 |
add_filter('the_content', array($this, 'filter_the_content'), 10, 2); |
| 333 |
add_filter('woocommerce_email_attachments', array($this, 'filter_woocommerce_email_attachments'), 10, 4); |
| 334 |
add_filter('woocommerce_mail_content', array($this, 'filter_woocommerce_mail_content'), 99); |
| 335 |
add_filter('woocommerce_display_product_attributes', array($this, 'filter_woocommerce_display_product_attributes'), 10, 2); |
| 336 |
add_filter('e2pdf_model_shortcode_wc_product_get_attribute_value', array($this, 'filter_e2pdf_model_shortcode_wc_product_get_attribute_value'), 10, 2); |
| 337 |
add_filter('woocommerce_customer_available_downloads', array($this, 'filter_download_urls')); |
| 338 |
add_filter('woocommerce_order_get_downloadable_items', array($this, 'filter_download_urls')); |
| 339 |
|
| 340 |
/* Flatsome theme global tab content */ |
| 341 |
add_filter('theme_mod_tab_content', array($this, 'filter_content_custom')); |
| 342 |
|
| 343 |
/* Variable Product Short Description Dynamic ID */ |
| 344 |
add_filter('woocommerce_available_variation', array($this, 'filter_woocommerce_available_variation'), 10, 3); |
| 345 |
|
| 346 |
/* PDF download link with E2Pdf shortcodes */ |
| 347 |
add_filter('e2pdf_model_shortcode_e2pdf_wc_product_description', array($this, 'filter_the_content'), 10, 2); |
| 348 |
|
| 349 |
/* Compatibility fix with Enforcing Rules enabled */ |
| 350 |
add_filter('woocommerce_product_downloads_approved_directory_validation_for_shortcodes', array($this, 'filter_woocommerce_product_downloads_approved_directory_validation_for_shortcodes'), 99); |
| 351 |
|
| 352 |
/** |
| 353 |
* Cornerstone Builder |
| 354 |
* https://theme.co/cornerstone/ |
| 355 |
*/ |
| 356 |
add_filter('cs_element_pre_render', array($this, 'filter_cs_element_pre_render')); |
| 357 |
|
| 358 |
/* Order Hooks */ |
| 359 |
add_filter('manage_edit-shop_order_columns', array($this, 'hook_woocommerce_order_row_column')); |
| 360 |
add_filter('woocommerce_my_account_my_orders_actions', array($this, 'hook_woocommerce_my_account_my_orders_actions'), 10, 2); |
| 361 |
|
| 362 |
/* Subscription Hooks */ |
| 363 |
add_filter('manage_edit-shop_subscription_columns', array($this, 'hook_woocommerce_subscription_row_column'), 11); |
| 364 |
add_filter('wcs_view_subscription_actions', array($this, 'hook_wcs_view_subscription_actions'), 11, 2); |
| 365 |
|
| 366 |
//phpcs:disable |
| 367 |
if (get_option('e2pdf_wc_my_orders_actions_template_id', '0')) { |
| 368 |
add_filter('woocommerce_my_account_my_orders_actions', array($this, 'filter_woocommerce_my_account_my_orders_actions'), (int) get_option('e2pdf_wc_checkout_template_id_priority', '10'), 2); |
| 369 |
} |
| 370 |
add_filter('e2pdf_model_options_get_options_options', array($this, 'filter_e2pdf_model_options_get_options_options')); |
| 371 |
//phpcs:enable |
| 372 |
} |
| 373 |
|
| 374 |
// action after email |
| 375 |
public function action_after_email() { |
| 376 |
$files = $this->helper->get('woocommerce_attachments'); |
| 377 |
if (is_array($files) && !empty($files)) { |
| 378 |
foreach ($files as $key => $file) { |
| 379 |
$this->helper->delete_dir(dirname($file) . '/'); |
| 380 |
} |
| 381 |
$this->helper->deset('woocommerce_attachments'); |
| 382 |
} |
| 383 |
} |
| 384 |
|
| 385 |
public function action_enforcing_rules_enabled_check() { |
| 386 |
if (get_option('wc_downloads_approved_directories_mode') === 'enabled') { |
| 387 |
if (class_exists('Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Register')) { |
| 388 |
try { |
| 389 |
$download_directories = wc_get_container()->get(Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Register::class); |
| 390 |
$directory_id = $download_directories->add_approved_directory('file://./'); |
| 391 |
if ($directory_id) { |
| 392 |
$download_directories->enable_by_id($directory_id); |
| 393 |
} |
| 394 |
} catch (Exception $e) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch |
| 395 |
} |
| 396 |
} |
| 397 |
} |
| 398 |
} |
| 399 |
|
| 400 |
public function filter_cs_element_pre_render($data) { |
| 401 |
if (!empty($data['_type']) && $data['_type'] == 'raw-content' && !empty($data['raw_content']) && !empty($data['_p'])) { |
| 402 |
$data['raw_content'] = $this->filter_content($data['raw_content'], $data['_p']); |
| 403 |
} |
| 404 |
return $data; |
| 405 |
} |
| 406 |
|
| 407 |
public function action_elementor_widget_before_render_content($widget) { |
| 408 |
if ($widget && ($widget->get_name() == 'shortcode' || $widget->get_name() == 'text-editor')) { |
| 409 |
$content = $widget->get_name() == 'shortcode' ? $widget->get_settings('shortcode') : $widget->get_settings('editor'); |
| 410 |
if ($content && false !== strpos($content, '[e2pdf-')) { |
| 411 |
$wp_reset_postdata = true; |
| 412 |
if (class_exists('\ElementorPro\Plugin') && class_exists('\ElementorPro\Modules\LoopBuilder\Documents\Loop')) { |
| 413 |
$document = \ElementorPro\Plugin::elementor()->documents->get_current(); |
| 414 |
if ($document && $document instanceof \ElementorPro\Modules\LoopBuilder\Documents\Loop) { |
| 415 |
$wp_reset_postdata = false; |
| 416 |
} |
| 417 |
} |
| 418 |
if ($widget->get_name() == 'shortcode') { |
| 419 |
$widget->set_settings('shortcode', $this->filter_content($content, false, false, $wp_reset_postdata)); |
| 420 |
} elseif ($widget->get_name() == 'text-editor' && !$wp_reset_postdata) { |
| 421 |
$widget->set_settings('editor', $this->filter_content($content, false, false, $wp_reset_postdata)); |
| 422 |
} |
| 423 |
} |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
public function action_add_meta_boxes_woocommerce_page_wc_orders($post) { |
| 428 |
if (class_exists('Automattic\WooCommerce\Utilities\OrderUtil') && method_exists('Automattic\WooCommerce\Utilities\OrderUtil', 'is_order_edit_screen') && class_exists('WC_Data_Store')) { |
| 429 |
if (Automattic\WooCommerce\Utilities\OrderUtil::is_order_edit_screen() || Automattic\WooCommerce\Utilities\OrderUtil::is_order_edit_screen('shop_subscription')) { |
| 430 |
if ($post instanceof WC_Order) { |
| 431 |
$order_id = $post->get_id(); |
| 432 |
} else { |
| 433 |
$order_id = $post->ID; |
| 434 |
} |
| 435 |
$data_store = WC_Data_Store::load('customer-download'); |
| 436 |
$download_permissions = array(); |
| 437 |
if (0 !== $order_id) { |
| 438 |
$download_permissions = $data_store->get_downloads( |
| 439 |
array( |
| 440 |
'order_id' => $order_id, |
| 441 |
'orderby' => 'product_id', |
| 442 |
) |
| 443 |
); |
| 444 |
} |
| 445 |
$product = null; |
| 446 |
$items = array(); |
| 447 |
$download_links = array(); |
| 448 |
if ($download_permissions && count($download_permissions) > 0) { |
| 449 |
foreach ($download_permissions as $download) { |
| 450 |
if (!$product || $product->get_id() !== $download->get_product_id()) { |
| 451 |
$product = wc_get_product($download->get_product_id()); |
| 452 |
} |
| 453 |
if (!$product || !$product->exists() || !$product->has_file($download->get_download_id())) { |
| 454 |
continue; |
| 455 |
} |
| 456 |
$file = $product->get_file($download->get_download_id()); |
| 457 |
if ($file && $file->get_file() && strpos($file->get_file(), '[e2pdf-download') !== false) { |
| 458 |
global $wpdb; |
| 459 |
if (isset($items[$download->get_download_id()])) { |
| 460 |
$item_ids = $items[$download->get_download_id()]; |
| 461 |
} else { |
| 462 |
$item_ids = array(); |
| 463 |
} |
| 464 |
$item_id = $wpdb->get_var($wpdb->prepare('SELECT `items`.`order_item_id` FROM `' . $wpdb->prefix . 'woocommerce_order_items` `items` INNER JOIN `' . $wpdb->prefix . "woocommerce_order_itemmeta` `itemmeta` ON `itemmeta`.`order_item_id` = `items`.`order_item_id` AND (`itemmeta`.`meta_key` = '_product_id' OR `itemmeta`.`meta_key` = '_variation_id' ) AND `itemmeta`.`meta_value` = %d WHERE `items`.`order_id` = %d and `items`.`order_item_type` = 'line_item' and `items`.`order_item_id` NOT IN ( '" . implode("','", $item_ids) . "' ) ORDER BY `items`.`order_item_id` ASC", $download->get_product_id(), $download->get_order_id())); |
| 465 |
if ($item_id) { |
| 466 |
$items[$download->get_download_id()][] = $item_id; |
| 467 |
$download_link = add_query_arg( |
| 468 |
array( |
| 469 |
'download_file' => $download->get_product_id(), |
| 470 |
'order' => $download->get_order_key(), |
| 471 |
'email' => urlencode($download->get_user_email()), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.urlencode_urlencode |
| 472 |
'key' => $download->get_download_id(), |
| 473 |
), |
| 474 |
trailingslashit(home_url()) |
| 475 |
); |
| 476 |
$download_links[] = array( |
| 477 |
's' => $download->get_download_id(), |
| 478 |
'r' => add_query_arg(array('item_id' => $item_id), $download_link), |
| 479 |
); |
| 480 |
} |
| 481 |
} |
| 482 |
} |
| 483 |
} |
| 484 |
if (!empty($download_links)) { |
| 485 |
add_action( |
| 486 |
'admin_print_scripts', function () use ($download_links) { |
| 487 |
echo '<script>const e2pdf_wc_download_links = ' . wp_json_encode($download_links) . ';document.addEventListener("DOMContentLoaded", function(event) {for (var i = 0; i < e2pdf_wc_download_links.length; i++){var a = document.querySelector(\'a[id="copy-download-link"][href$="\'+e2pdf_wc_download_links[i][\'s\']+\'"]\');if (a) {a.setAttribute(\'href\',e2pdf_wc_download_links[i][\'r\']);}}});</script>'; |
| 488 |
} |
| 489 |
); |
| 490 |
} |
| 491 |
} |
| 492 |
} |
| 493 |
} |
| 494 |
|
| 495 |
public function filter_woocommerce_available_variation($data, $wc_product_variable, $variation) { |
| 496 |
$description = $variation->get_description(); |
| 497 |
if ($description && false !== strpos($description, '[e2pdf-download') || false !== strpos($description, '[e2pdf-save') || false !== strpos($description, '[e2pdf-view') || false !== strpos($description, '[e2pdf-adobesign') || false !== strpos($description, '[e2pdf-zapier')) { |
| 498 |
$description = $this->filter_the_content($description, $variation->get_variation_id()); |
| 499 |
$data['variation_description'] = wc_format_content($description); |
| 500 |
} |
| 501 |
return $data; |
| 502 |
} |
| 503 |
|
| 504 |
public function filter_woocommerce_mail_content($message) { |
| 505 |
if ($message) { |
| 506 |
if (false !== strpos($message, '[e2pdf-attachment') || false !== strpos($message, '[e2pdf-save') || false !== strpos($message, '[e2pdf-zapier')) { |
| 507 |
$message = preg_replace('~(?:\[(e2pdf-attachment|e2pdf-save|e2pdf-zapier)/?)\s[^\]]+/?\]~s', '', $message); |
| 508 |
} |
| 509 |
} |
| 510 |
return $message; |
| 511 |
} |
| 512 |
|
| 513 |
public function filter_woocommerce_email_attachments($attachments, $wc_email_id, $order, $wc_email) { |
| 514 |
if ($wc_email_id == 'ywgc-email-send-gift-card') { |
| 515 |
$ywgc_gift_post_id = isset($order->ID) ? $order->ID : false; |
| 516 |
$ywgc_order_item_id = get_post_meta($ywgc_gift_post_id, '_ywgc_order_item_id', true); |
| 517 |
$order = wc_get_order(isset($order->order_id) ? $order->order_id : false); |
| 518 |
} |
| 519 |
if ($order && is_object($order) && method_exists($order, 'get_id') && $wc_email && is_object($wc_email) && method_exists($wc_email, 'get_additional_content')) { |
| 520 |
if ($wc_email_id == 'ywgc-email-send-gift-card') { |
| 521 |
$additional_content = isset($wc_email->introductory_text) ? $wc_email->introductory_text : ''; |
| 522 |
$additional_content = str_replace( |
| 523 |
array( |
| 524 |
'{recipient_email}', |
| 525 |
), |
| 526 |
array( |
| 527 |
isset($wc_email->recipient) ? $wc_email->recipient : '', |
| 528 |
), |
| 529 |
$additional_content |
| 530 |
); |
| 531 |
} else { |
| 532 |
$additional_content = $wc_email->get_additional_content(); |
| 533 |
} |
| 534 |
if (false !== strpos($additional_content, '[')) { |
| 535 |
$shortcode_tags = array( |
| 536 |
'e2pdf-attachment', |
| 537 |
'e2pdf-save', |
| 538 |
'e2pdf-zapier', |
| 539 |
); |
| 540 |
preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $additional_content, $matches); |
| 541 |
$tagnames = array_intersect($shortcode_tags, $matches[1]); |
| 542 |
if (!empty($tagnames)) { |
| 543 |
$items = array(); |
| 544 |
$items_variation = array(); |
| 545 |
$items_product = array(); |
| 546 |
if (method_exists($order, 'get_items')) { |
| 547 |
$order_items = $order->get_items(); |
| 548 |
foreach ($order_items as $item_id => $order_item) { |
| 549 |
$items[$item_id] = $order_item->get_product_id(); |
| 550 |
if ($order_item->get_variation_id()) { |
| 551 |
$items_variation[$item_id] = $order_item->get_variation_id(); |
| 552 |
} else { |
| 553 |
$items_product[$item_id] = $order_item->get_product_id(); |
| 554 |
} |
| 555 |
} |
| 556 |
} |
| 557 |
preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $additional_content, $shortcodes); |
| 558 |
foreach ($shortcodes[0] as $key => $shortcode_value) { |
| 559 |
$shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key); |
| 560 |
$atts = shortcode_parse_atts($shortcode[3]); |
| 561 |
$file = false; |
| 562 |
$template = new Model_E2pdf_Template(); |
| 563 |
if (isset($atts['id']) && $atts['id']) { |
| 564 |
$template->load($atts['id']); |
| 565 |
} |
| 566 |
$attributes = array(); |
| 567 |
foreach ($atts as $att_key => $att) { |
| 568 |
if (strpos($att_key, 'attribute_') === 0) { |
| 569 |
$attributes[substr($att_key, 10)] = $att; |
| 570 |
} |
| 571 |
} |
| 572 |
if (isset($atts['product_ids']) && $atts['product_ids']) { |
| 573 |
$atts['products'] = $atts['product_ids']; |
| 574 |
} |
| 575 |
if ($template->get('extension') === 'gravity') { |
| 576 |
if (!isset($atts['dataset'])) { |
| 577 |
foreach ($items as $item_id => $item) { |
| 578 |
$linked_entry_id = false; |
| 579 |
if ($linked_data = wc_get_order_item_meta($item_id, '_gravity_forms_history', true)) { |
| 580 |
if (!empty($linked_data['_gravity_form_linked_entry_id'])) { |
| 581 |
$linked_entry_id = $linked_data['_gravity_form_linked_entry_id']; |
| 582 |
} |
| 583 |
} elseif ($linked_data = wc_get_order_item_meta($item_id, 'gspc_gf_entry_ids', true)) { |
| 584 |
if (!empty($linked_data) && isset($linked_data[0])) { |
| 585 |
$linked_entry_id = $linked_data[0]; |
| 586 |
} |
| 587 |
} |
| 588 |
if ($linked_entry_id) { |
| 589 |
$attachment = true; |
| 590 |
if ($attachment) { |
| 591 |
if (!empty($attributes)) { |
| 592 |
$product = wc_get_product($item); |
| 593 |
if ($product) { |
| 594 |
foreach ($attributes as $attribute_key => $attribute) { |
| 595 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 596 |
$attachment = false; |
| 597 |
break; |
| 598 |
} |
| 599 |
} |
| 600 |
} else { |
| 601 |
$attachment = false; |
| 602 |
} |
| 603 |
} |
| 604 |
} |
| 605 |
if ($attachment) { |
| 606 |
if (isset($atts['products']) && $atts['products']) { |
| 607 |
$attachment = false; |
| 608 |
$products = explode(',', $atts['products']); |
| 609 |
if (in_array($item, $products, false)) { |
| 610 |
$attachment = true; |
| 611 |
} else { |
| 612 |
$product = wc_get_product($item); |
| 613 |
if ($product && method_exists($product, 'get_parent_id')) { |
| 614 |
if (in_array($product->get_parent_id(), $products, false)) { |
| 615 |
$attachment = true; |
| 616 |
} |
| 617 |
} |
| 618 |
} |
| 619 |
} |
| 620 |
} |
| 621 |
if ($attachment) { |
| 622 |
if (isset($atts['categories']) && $atts['categories']) { |
| 623 |
$attachment = false; |
| 624 |
$categories = explode(',', $atts['categories']); |
| 625 |
if (has_term($categories, 'product_cat', $item)) { |
| 626 |
$attachment = true; |
| 627 |
} |
| 628 |
} |
| 629 |
} |
| 630 |
if ($attachment) { |
| 631 |
if (isset($atts['tags']) && $atts['tags']) { |
| 632 |
$attachment = false; |
| 633 |
$tags = explode(',', $atts['tags']); |
| 634 |
if (has_term($tags, 'product_tag', $item)) { |
| 635 |
$attachment = true; |
| 636 |
} |
| 637 |
} |
| 638 |
} |
| 639 |
if ($attachment) { |
| 640 |
$item_shortcode = $shortcode; |
| 641 |
if (!isset($atts['apply'])) { |
| 642 |
$item_shortcode[3] .= ' apply="true"'; |
| 643 |
} |
| 644 |
if (!isset($atts['filter'])) { |
| 645 |
$item_shortcode[3] .= ' filter="true"'; |
| 646 |
} |
| 647 |
$item_shortcode[3] .= ' dataset="' . $linked_entry_id . '"'; |
| 648 |
if ($this->helper->load('shortcode')->is_attachment($item_shortcode, $atts)) { |
| 649 |
$file = do_shortcode_tag($item_shortcode); |
| 650 |
if ($file) { |
| 651 |
$tmp = false; |
| 652 |
if (substr($file, 0, 4) === 'tmp:') { |
| 653 |
$file = substr($file, 4); |
| 654 |
$tmp = true; |
| 655 |
} |
| 656 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 657 |
if ($tmp) { |
| 658 |
$this->helper->add('woocommerce_attachments', $file); |
| 659 |
} |
| 660 |
} else { |
| 661 |
$this->helper->add('woocommerce_attachments', $file); |
| 662 |
} |
| 663 |
$attachments[] = $file; |
| 664 |
} |
| 665 |
} elseif ($item_shortcode[2] === 'e2pdf-zapier' || $item_shortcode[2] === 'e2pdf-save') { |
| 666 |
do_shortcode_tag($item_shortcode); |
| 667 |
} |
| 668 |
} |
| 669 |
} |
| 670 |
} |
| 671 |
} |
| 672 |
} elseif ($template->get('extension') === 'formidable') { |
| 673 |
if (!isset($atts['dataset'])) { |
| 674 |
foreach ($items as $item_id => $item) { |
| 675 |
$_formidable_form_data = wc_get_order_item_meta($item_id, '_formidable_form_data', true); |
| 676 |
if ($_formidable_form_data) { |
| 677 |
$attachment = true; |
| 678 |
if ($attachment) { |
| 679 |
if (!empty($attributes)) { |
| 680 |
$product = wc_get_product($item); |
| 681 |
if ($product) { |
| 682 |
foreach ($attributes as $attribute_key => $attribute) { |
| 683 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 684 |
$attachment = false; |
| 685 |
break; |
| 686 |
} |
| 687 |
} |
| 688 |
} else { |
| 689 |
$attachment = false; |
| 690 |
} |
| 691 |
} |
| 692 |
} |
| 693 |
if ($attachment) { |
| 694 |
if (isset($atts['products']) && $atts['products']) { |
| 695 |
$attachment = false; |
| 696 |
$products = explode(',', $atts['products']); |
| 697 |
if (in_array($item, $products, false)) { |
| 698 |
$attachment = true; |
| 699 |
} else { |
| 700 |
$product = wc_get_product($item); |
| 701 |
if ($product && method_exists($product, 'get_parent_id')) { |
| 702 |
if (in_array($product->get_parent_id(), $products, false)) { |
| 703 |
$attachment = true; |
| 704 |
} |
| 705 |
} |
| 706 |
} |
| 707 |
} |
| 708 |
} |
| 709 |
if ($attachment) { |
| 710 |
if (isset($atts['categories']) && $atts['categories']) { |
| 711 |
$attachment = false; |
| 712 |
$categories = explode(',', $atts['categories']); |
| 713 |
if (has_term($categories, 'product_cat', $item)) { |
| 714 |
$attachment = true; |
| 715 |
} |
| 716 |
} |
| 717 |
} |
| 718 |
if ($attachment) { |
| 719 |
if (isset($atts['tags']) && $atts['tags']) { |
| 720 |
$attachment = false; |
| 721 |
$tags = explode(',', $atts['tags']); |
| 722 |
if (has_term($tags, 'product_tag', $item)) { |
| 723 |
$attachment = true; |
| 724 |
} |
| 725 |
} |
| 726 |
} |
| 727 |
if ($attachment) { |
| 728 |
$item_shortcode = $shortcode; |
| 729 |
if (!isset($atts['apply'])) { |
| 730 |
$item_shortcode[3] .= ' apply="true"'; |
| 731 |
} |
| 732 |
if (!isset($atts['filter'])) { |
| 733 |
$item_shortcode[3] .= ' filter="true"'; |
| 734 |
} |
| 735 |
$item_shortcode[3] .= ' dataset="' . $_formidable_form_data . '"'; |
| 736 |
if ($this->helper->load('shortcode')->is_attachment($item_shortcode, $atts)) { |
| 737 |
$file = do_shortcode_tag($item_shortcode); |
| 738 |
if ($file) { |
| 739 |
$tmp = false; |
| 740 |
if (substr($file, 0, 4) === 'tmp:') { |
| 741 |
$file = substr($file, 4); |
| 742 |
$tmp = true; |
| 743 |
} |
| 744 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 745 |
if ($tmp) { |
| 746 |
$this->helper->add('woocommerce_attachments', $file); |
| 747 |
} |
| 748 |
} else { |
| 749 |
$this->helper->add('woocommerce_attachments', $file); |
| 750 |
} |
| 751 |
$attachments[] = $file; |
| 752 |
} |
| 753 |
} elseif ($item_shortcode[2] === 'e2pdf-zapier' || $item_shortcode[2] === 'e2pdf-save') { |
| 754 |
do_shortcode_tag($item_shortcode); |
| 755 |
} |
| 756 |
} |
| 757 |
} |
| 758 |
} |
| 759 |
} |
| 760 |
} elseif ($wc_email_id == 'ywgc-email-send-gift-card' && $template->get('extension') === 'wordpress') { // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled |
| 761 |
if ($template->get('item') == 'gift_card') { |
| 762 |
if (isset($atts['dataset'])) { |
| 763 |
foreach ($items_product as $item_id => $item) { |
| 764 |
if ($ywgc_order_item_id != $item_id) { |
| 765 |
continue; |
| 766 |
} |
| 767 |
if ($item == $atts['dataset']) { |
| 768 |
$attachment = true; |
| 769 |
if ($attachment) { |
| 770 |
if (!empty($attributes)) { |
| 771 |
$product = wc_get_product($item); |
| 772 |
if ($product) { |
| 773 |
foreach ($attributes as $attribute_key => $attribute) { |
| 774 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 775 |
$attachment = false; |
| 776 |
break; |
| 777 |
} |
| 778 |
} |
| 779 |
} else { |
| 780 |
$attachment = false; |
| 781 |
} |
| 782 |
} |
| 783 |
} |
| 784 |
if ($attachment) { |
| 785 |
$item_shortcode = $shortcode; |
| 786 |
if (!isset($atts['apply'])) { |
| 787 |
$item_shortcode[3] .= ' apply="true"'; |
| 788 |
} |
| 789 |
if (!isset($atts['filter'])) { |
| 790 |
$item_shortcode[3] .= ' filter="true"'; |
| 791 |
} |
| 792 |
$item_shortcode[3] .= ' dataset="' . $ywgc_gift_post_id . '"'; |
| 793 |
if ($this->helper->load('shortcode')->is_attachment($item_shortcode, $atts)) { |
| 794 |
$file = do_shortcode_tag($item_shortcode); |
| 795 |
if ($file) { |
| 796 |
$tmp = false; |
| 797 |
if (substr($file, 0, 4) === 'tmp:') { |
| 798 |
$file = substr($file, 4); |
| 799 |
$tmp = true; |
| 800 |
} |
| 801 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 802 |
if ($tmp) { |
| 803 |
$file = substr($file, 4); |
| 804 |
$this->helper->add('woocommerce_attachments', $file); |
| 805 |
} |
| 806 |
} else { |
| 807 |
$this->helper->add('woocommerce_attachments', $file); |
| 808 |
} |
| 809 |
$attachments[] = $file; |
| 810 |
} |
| 811 |
} elseif ($item_shortcode[2] === 'e2pdf-zapier' || $item_shortcode[2] === 'e2pdf-save') { |
| 812 |
do_shortcode_tag($item_shortcode); |
| 813 |
} |
| 814 |
} |
| 815 |
} |
| 816 |
} |
| 817 |
} elseif (!isset($atts['dataset'])) { |
| 818 |
foreach ($items_product as $item_id => $item) { |
| 819 |
if ($ywgc_order_item_id != $item_id) { |
| 820 |
continue; |
| 821 |
} |
| 822 |
$attachment = true; |
| 823 |
if ($attachment) { |
| 824 |
if (!empty($attributes)) { |
| 825 |
$product = wc_get_product($item); |
| 826 |
if ($product) { |
| 827 |
foreach ($attributes as $attribute_key => $attribute) { |
| 828 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 829 |
$attachment = false; |
| 830 |
break; |
| 831 |
} |
| 832 |
} |
| 833 |
} else { |
| 834 |
$attachment = false; |
| 835 |
} |
| 836 |
} |
| 837 |
} |
| 838 |
if ($attachment) { |
| 839 |
if (isset($atts['products']) && $atts['products']) { |
| 840 |
$attachment = false; |
| 841 |
$products = explode(',', $atts['products']); |
| 842 |
if (in_array($item, $products, false)) { |
| 843 |
$attachment = true; |
| 844 |
} |
| 845 |
} |
| 846 |
} |
| 847 |
if ($attachment) { |
| 848 |
if (isset($atts['categories']) && $atts['categories']) { |
| 849 |
$attachment = false; |
| 850 |
$categories = explode(',', $atts['categories']); |
| 851 |
if (has_term($categories, 'product_cat', $item)) { |
| 852 |
$attachment = true; |
| 853 |
} |
| 854 |
} |
| 855 |
} |
| 856 |
if ($attachment) { |
| 857 |
if (isset($atts['tags']) && $atts['tags']) { |
| 858 |
$attachment = false; |
| 859 |
$tags = explode(',', $atts['tags']); |
| 860 |
if (has_term($tags, 'product_tag', $item)) { |
| 861 |
$attachment = true; |
| 862 |
} |
| 863 |
} |
| 864 |
} |
| 865 |
if ($attachment) { |
| 866 |
$item_shortcode = $shortcode; |
| 867 |
if (!isset($atts['apply'])) { |
| 868 |
$item_shortcode[3] .= ' apply="true"'; |
| 869 |
} |
| 870 |
if (!isset($atts['filter'])) { |
| 871 |
$item_shortcode[3] .= ' filter="true"'; |
| 872 |
} |
| 873 |
$item_shortcode[3] .= ' dataset="' . $ywgc_gift_post_id . '"'; |
| 874 |
if ($this->helper->load('shortcode')->is_attachment($item_shortcode, $atts)) { |
| 875 |
$file = do_shortcode_tag($item_shortcode); |
| 876 |
if ($file) { |
| 877 |
$tmp = false; |
| 878 |
if (substr($file, 0, 4) === 'tmp:') { |
| 879 |
$file = substr($file, 4); |
| 880 |
$tmp = true; |
| 881 |
} |
| 882 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 883 |
if ($tmp) { |
| 884 |
$this->helper->add('woocommerce_attachments', $file); |
| 885 |
} |
| 886 |
} else { |
| 887 |
$this->helper->add('woocommerce_attachments', $file); |
| 888 |
} |
| 889 |
$attachments[] = $file; |
| 890 |
} |
| 891 |
} elseif ($item_shortcode[2] === 'e2pdf-zapier' || $item_shortcode[2] === 'e2pdf-save') { |
| 892 |
do_shortcode_tag($item_shortcode); |
| 893 |
} |
| 894 |
} |
| 895 |
} |
| 896 |
} |
| 897 |
} |
| 898 |
} elseif ($template->get('extension') === 'woocommerce') { |
| 899 |
if ($template->get('item') == 'product') { |
| 900 |
if (isset($atts['dataset'])) { |
| 901 |
foreach ($items_product as $item_id => $item) { |
| 902 |
if ($wc_email_id == 'ywgc-email-send-gift-card' && $ywgc_order_item_id != $item_id) { |
| 903 |
continue; |
| 904 |
} |
| 905 |
if ($item == $atts['dataset']) { |
| 906 |
$attachment = true; |
| 907 |
if ($attachment) { |
| 908 |
if (!empty($attributes)) { |
| 909 |
$product = wc_get_product($item); |
| 910 |
if ($product) { |
| 911 |
foreach ($attributes as $attribute_key => $attribute) { |
| 912 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 913 |
$attachment = false; |
| 914 |
break; |
| 915 |
} |
| 916 |
} |
| 917 |
} else { |
| 918 |
$attachment = false; |
| 919 |
} |
| 920 |
} |
| 921 |
} |
| 922 |
if ($attachment) { |
| 923 |
$item_shortcode = $shortcode; |
| 924 |
if (!isset($atts['apply'])) { |
| 925 |
$item_shortcode[3] .= ' apply="true"'; |
| 926 |
} |
| 927 |
if (!isset($atts['filter'])) { |
| 928 |
$item_shortcode[3] .= ' filter="true"'; |
| 929 |
} |
| 930 |
if (!isset($atts['wc_order_id'])) { |
| 931 |
$item_shortcode[3] .= ' wc_order_id="' . $order->get_id() . '"'; |
| 932 |
} |
| 933 |
if (!isset($atts['wc_product_item_id'])) { |
| 934 |
$item_shortcode[3] .= ' wc_product_item_id="' . $item_id . '"'; |
| 935 |
} |
| 936 |
|
| 937 |
if ($this->helper->load('shortcode')->is_attachment($item_shortcode, $atts)) { |
| 938 |
$file = do_shortcode_tag($item_shortcode); |
| 939 |
if ($file) { |
| 940 |
$tmp = false; |
| 941 |
if (substr($file, 0, 4) === 'tmp:') { |
| 942 |
$file = substr($file, 4); |
| 943 |
$tmp = true; |
| 944 |
} |
| 945 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 946 |
if ($tmp) { |
| 947 |
$file = substr($file, 4); |
| 948 |
$this->helper->add('woocommerce_attachments', $file); |
| 949 |
} |
| 950 |
} else { |
| 951 |
$this->helper->add('woocommerce_attachments', $file); |
| 952 |
} |
| 953 |
$attachments[] = $file; |
| 954 |
} |
| 955 |
} elseif ($item_shortcode[2] === 'e2pdf-zapier' || $item_shortcode[2] === 'e2pdf-save') { |
| 956 |
do_shortcode_tag($item_shortcode); |
| 957 |
} |
| 958 |
} |
| 959 |
} |
| 960 |
} |
| 961 |
} elseif (!isset($atts['dataset'])) { |
| 962 |
foreach ($items_product as $item_id => $item) { |
| 963 |
if ($wc_email_id == 'ywgc-email-send-gift-card' && $ywgc_order_item_id != $item_id) { |
| 964 |
continue; |
| 965 |
} |
| 966 |
$attachment = true; |
| 967 |
if ($attachment) { |
| 968 |
if (!empty($attributes)) { |
| 969 |
$product = wc_get_product($item); |
| 970 |
if ($product) { |
| 971 |
foreach ($attributes as $attribute_key => $attribute) { |
| 972 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 973 |
$attachment = false; |
| 974 |
break; |
| 975 |
} |
| 976 |
} |
| 977 |
} else { |
| 978 |
$attachment = false; |
| 979 |
} |
| 980 |
} |
| 981 |
} |
| 982 |
if ($attachment) { |
| 983 |
if (isset($atts['products']) && $atts['products']) { |
| 984 |
$attachment = false; |
| 985 |
$products = explode(',', $atts['products']); |
| 986 |
if (in_array($item, $products, false)) { |
| 987 |
$attachment = true; |
| 988 |
} |
| 989 |
} |
| 990 |
} |
| 991 |
if ($attachment) { |
| 992 |
if (isset($atts['categories']) && $atts['categories']) { |
| 993 |
$attachment = false; |
| 994 |
$categories = explode(',', $atts['categories']); |
| 995 |
if (has_term($categories, 'product_cat', $item)) { |
| 996 |
$attachment = true; |
| 997 |
} |
| 998 |
} |
| 999 |
} |
| 1000 |
if ($attachment) { |
| 1001 |
if (isset($atts['tags']) && $atts['tags']) { |
| 1002 |
$attachment = false; |
| 1003 |
$tags = explode(',', $atts['tags']); |
| 1004 |
if (has_term($tags, 'product_tag', $item)) { |
| 1005 |
$attachment = true; |
| 1006 |
} |
| 1007 |
} |
| 1008 |
} |
| 1009 |
if ($attachment) { |
| 1010 |
$item_shortcode = $shortcode; |
| 1011 |
if (!isset($atts['apply'])) { |
| 1012 |
$item_shortcode[3] .= ' apply="true"'; |
| 1013 |
} |
| 1014 |
if (!isset($atts['filter'])) { |
| 1015 |
$item_shortcode[3] .= ' filter="true"'; |
| 1016 |
} |
| 1017 |
if (!isset($atts['wc_order_id'])) { |
| 1018 |
$item_shortcode[3] .= ' wc_order_id="' . $order->get_id() . '"'; |
| 1019 |
} |
| 1020 |
if (!isset($atts['wc_product_item_id'])) { |
| 1021 |
$item_shortcode[3] .= ' wc_product_item_id="' . $item_id . '"'; |
| 1022 |
} |
| 1023 |
$item_shortcode[3] .= ' dataset="' . $item . '"'; |
| 1024 |
if ($this->helper->load('shortcode')->is_attachment($item_shortcode, $atts)) { |
| 1025 |
$file = do_shortcode_tag($item_shortcode); |
| 1026 |
if ($file) { |
| 1027 |
$tmp = false; |
| 1028 |
if (substr($file, 0, 4) === 'tmp:') { |
| 1029 |
$file = substr($file, 4); |
| 1030 |
$tmp = true; |
| 1031 |
} |
| 1032 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 1033 |
if ($tmp) { |
| 1034 |
$this->helper->add('woocommerce_attachments', $file); |
| 1035 |
} |
| 1036 |
} else { |
| 1037 |
$this->helper->add('woocommerce_attachments', $file); |
| 1038 |
} |
| 1039 |
$attachments[] = $file; |
| 1040 |
} |
| 1041 |
} elseif ($item_shortcode[2] === 'e2pdf-zapier' || $item_shortcode[2] === 'e2pdf-save') { |
| 1042 |
do_shortcode_tag($item_shortcode); |
| 1043 |
} |
| 1044 |
} |
| 1045 |
} |
| 1046 |
} |
| 1047 |
} elseif ($template->get('item') == 'product_variation') { |
| 1048 |
if (isset($atts['dataset'])) { |
| 1049 |
foreach ($items_variation as $item_id => $item) { |
| 1050 |
if ($item == $atts['dataset']) { |
| 1051 |
$attachment = true; |
| 1052 |
if ($attachment) { |
| 1053 |
if (!empty($attributes)) { |
| 1054 |
$product = wc_get_product($item); |
| 1055 |
if ($product) { |
| 1056 |
foreach ($attributes as $attribute_key => $attribute) { |
| 1057 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 1058 |
$attachment = false; |
| 1059 |
break; |
| 1060 |
} |
| 1061 |
} |
| 1062 |
} else { |
| 1063 |
$attachment = false; |
| 1064 |
} |
| 1065 |
} |
| 1066 |
} |
| 1067 |
if ($attachment) { |
| 1068 |
$item_shortcode = $shortcode; |
| 1069 |
if (!isset($atts['apply'])) { |
| 1070 |
$item_shortcode[3] .= ' apply="true"'; |
| 1071 |
} |
| 1072 |
if (!isset($atts['filter'])) { |
| 1073 |
$item_shortcode[3] .= ' filter="true"'; |
| 1074 |
} |
| 1075 |
if (!isset($atts['wc_order_id'])) { |
| 1076 |
$item_shortcode[3] .= ' wc_order_id="' . $order->get_id() . '"'; |
| 1077 |
} |
| 1078 |
if (!isset($atts['wc_product_item_id'])) { |
| 1079 |
$item_shortcode[3] .= ' wc_product_item_id="' . $item_id . '"'; |
| 1080 |
} |
| 1081 |
if ($this->helper->load('shortcode')->is_attachment($item_shortcode, $atts)) { |
| 1082 |
$file = do_shortcode_tag($item_shortcode); |
| 1083 |
if ($file) { |
| 1084 |
$tmp = false; |
| 1085 |
if (substr($file, 0, 4) === 'tmp:') { |
| 1086 |
$file = substr($file, 4); |
| 1087 |
$tmp = true; |
| 1088 |
} |
| 1089 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 1090 |
if ($tmp) { |
| 1091 |
$this->helper->add('woocommerce_attachments', $file); |
| 1092 |
} |
| 1093 |
} else { |
| 1094 |
$this->helper->add('woocommerce_attachments', $file); |
| 1095 |
} |
| 1096 |
$attachments[] = $file; |
| 1097 |
} |
| 1098 |
} elseif ($item_shortcode[2] === 'e2pdf-zapier' || $item_shortcode[2] === 'e2pdf-save') { |
| 1099 |
do_shortcode_tag($item_shortcode); |
| 1100 |
} |
| 1101 |
} |
| 1102 |
} |
| 1103 |
} |
| 1104 |
} elseif (!isset($atts['dataset'])) { |
| 1105 |
foreach ($items_variation as $item_id => $item) { |
| 1106 |
$attachment = true; |
| 1107 |
if ($attachment) { |
| 1108 |
if (!empty($attributes)) { |
| 1109 |
$product = wc_get_product($item); |
| 1110 |
if ($product) { |
| 1111 |
foreach ($attributes as $attribute_key => $attribute) { |
| 1112 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 1113 |
$attachment = false; |
| 1114 |
break; |
| 1115 |
} |
| 1116 |
} |
| 1117 |
} else { |
| 1118 |
$attachment = false; |
| 1119 |
} |
| 1120 |
} |
| 1121 |
} |
| 1122 |
if ($attachment) { |
| 1123 |
if (isset($atts['products']) && $atts['products']) { |
| 1124 |
$attachment = false; |
| 1125 |
$products = explode(',', $atts['products']); |
| 1126 |
if (in_array($item, $products, false)) { |
| 1127 |
$attachment = true; |
| 1128 |
} else { |
| 1129 |
$product = wc_get_product($item); |
| 1130 |
if ($product && method_exists($product, 'get_parent_id')) { |
| 1131 |
if (in_array($product->get_parent_id(), $products, false)) { |
| 1132 |
$attachment = true; |
| 1133 |
} |
| 1134 |
} |
| 1135 |
} |
| 1136 |
} |
| 1137 |
} |
| 1138 |
if ($attachment) { |
| 1139 |
if (isset($atts['categories']) && $atts['categories']) { |
| 1140 |
$attachment = false; |
| 1141 |
$categories = explode(',', $atts['categories']); |
| 1142 |
if (has_term($categories, 'product_cat', $item)) { |
| 1143 |
$attachment = true; |
| 1144 |
} |
| 1145 |
} |
| 1146 |
} |
| 1147 |
if ($attachment) { |
| 1148 |
if (isset($atts['tags']) && $atts['tags']) { |
| 1149 |
$attachment = false; |
| 1150 |
$tags = explode(',', $atts['tags']); |
| 1151 |
if (has_term($tags, 'product_tag', $item)) { |
| 1152 |
$attachment = true; |
| 1153 |
} |
| 1154 |
} |
| 1155 |
} |
| 1156 |
if ($attachment) { |
| 1157 |
$item_shortcode = $shortcode; |
| 1158 |
if (!isset($atts['apply'])) { |
| 1159 |
$item_shortcode[3] .= ' apply="true"'; |
| 1160 |
} |
| 1161 |
if (!isset($atts['filter'])) { |
| 1162 |
$item_shortcode[3] .= ' filter="true"'; |
| 1163 |
} |
| 1164 |
if (!isset($atts['wc_order_id'])) { |
| 1165 |
$item_shortcode[3] .= ' wc_order_id="' . $order->get_id() . '"'; |
| 1166 |
} |
| 1167 |
if (!isset($atts['wc_product_item_id'])) { |
| 1168 |
$item_shortcode[3] .= ' wc_product_item_id="' . $item_id . '"'; |
| 1169 |
} |
| 1170 |
$item_shortcode[3] .= ' dataset="' . $item . '"'; |
| 1171 |
if ($this->helper->load('shortcode')->is_attachment($item_shortcode, $atts)) { |
| 1172 |
$file = do_shortcode_tag($item_shortcode); |
| 1173 |
if ($file) { |
| 1174 |
$tmp = false; |
| 1175 |
if (substr($file, 0, 4) === 'tmp:') { |
| 1176 |
$file = substr($file, 4); |
| 1177 |
$tmp = true; |
| 1178 |
} |
| 1179 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 1180 |
if ($tmp) { |
| 1181 |
$this->helper->add('woocommerce_attachments', $file); |
| 1182 |
} |
| 1183 |
} else { |
| 1184 |
$this->helper->add('woocommerce_attachments', $file); |
| 1185 |
} |
| 1186 |
$attachments[] = $file; |
| 1187 |
} |
| 1188 |
} elseif ($item_shortcode[2] === 'e2pdf-zapier' || $item_shortcode[2] === 'e2pdf-save') { |
| 1189 |
do_shortcode_tag($item_shortcode); |
| 1190 |
} |
| 1191 |
} |
| 1192 |
} |
| 1193 |
} |
| 1194 |
} elseif ($template->get('item') == 'shop_subscription' && function_exists('wcs_get_subscriptions_for_order')) { |
| 1195 |
$subscriptions = wcs_get_subscriptions_for_order($order->get_id()); |
| 1196 |
foreach ($subscriptions as $subscription) { |
| 1197 |
if (!isset($atts['dataset'])) { |
| 1198 |
$attachment = true; |
| 1199 |
if ($attachment) { |
| 1200 |
if (!empty($attributes)) { |
| 1201 |
$attachment = false; |
| 1202 |
foreach ($items_product as $item_id => $item) { |
| 1203 |
$product = wc_get_product($item); |
| 1204 |
if ($product) { |
| 1205 |
foreach ($attributes as $attribute_key => $attribute) { |
| 1206 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 1207 |
$attachment = true; |
| 1208 |
break; |
| 1209 |
} |
| 1210 |
} |
| 1211 |
} |
| 1212 |
} |
| 1213 |
if (!$attachment) { |
| 1214 |
foreach ($items_variation as $item_id => $item) { |
| 1215 |
$product = wc_get_product($item); |
| 1216 |
if ($product) { |
| 1217 |
foreach ($attributes as $attribute_key => $attribute) { |
| 1218 |
if ($product->get_attribute($attribute_key) == $attribute) { |
| 1219 |
$attachment = true; |
| 1220 |
break; |
| 1221 |
} |
| 1222 |
} |
| 1223 |
} |
| 1224 |
} |
| 1225 |
} |
| 1226 |
} |
| 1227 |
} |
| 1228 |
if ($attachment) { |
| 1229 |
if (isset($atts['products']) && $atts['products']) { |
| 1230 |
$attachment = false; |
| 1231 |
$products = explode(',', $atts['products']); |
| 1232 |
foreach ($products as $product_id) { |
| 1233 |
if (in_array($product_id, $items, false) || in_array($product_id, $items_variation, false)) { |
| 1234 |
$attachment = true; |
| 1235 |
break; |
| 1236 |
} |
| 1237 |
} |
| 1238 |
} |
| 1239 |
} |
| 1240 |
if ($attachment) { |
| 1241 |
if (isset($atts['categories']) && $atts['categories']) { |
| 1242 |
$attachment = false; |
| 1243 |
$categories = explode(',', $atts['categories']); |
| 1244 |
foreach ($items as $item) { |
| 1245 |
if (has_term($categories, 'product_cat', $item)) { |
| 1246 |
$attachment = true; |
| 1247 |
break; |
| 1248 |
} |
| 1249 |
} |
| 1250 |
} |
| 1251 |
} |
| 1252 |
if ($attachment) { |
| 1253 |
if (isset($atts['tags']) && $atts['tags']) { |
| 1254 |
$attachment = false; |
| 1255 |
$tags = explode(',', $atts['tags']); |
| 1256 |
foreach ($items as $item) { |
| 1257 |
if (has_term($tags, 'product_tag', $item)) { |
| 1258 |
$attachment = true; |
| 1259 |
break; |
| 1260 |
} |
| 1261 |
} |
| 1262 |
} |
| 1263 |
} |
| 1264 |
if ($attachment) { |
| 1265 |
if (!isset($atts['apply'])) { |
| 1266 |
$shortcode[3] .= ' apply="true"'; |
| 1267 |
} |
| 1268 |
if (!isset($atts['filter'])) { |
| 1269 |
$shortcode[3] .= ' filter="true"'; |
| 1270 |
} |
| 1271 |
$shortcode[3] .= ' dataset="' . $subscription->get_id() . '"'; |
| 1272 |
if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) { |
| 1273 |
$file = do_shortcode_tag($shortcode); |
| 1274 |
if ($file) { |
| 1275 |
$tmp = false; |
| 1276 |
if (substr($file, 0, 4) === 'tmp:') { |
| 1277 |
$file = substr($file, 4); |
| 1278 |
$tmp = true; |
| 1279 |
} |
| 1280 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 1281 |
if ($tmp) { |
| 1282 |
$this->helper->add('woocommerce_attachments', $file); |
| 1283 |
} |
| 1284 |
} else { |
| 1285 |
$this->helper->add('woocommerce_attachments', $file); |
| 1286 |
} |
| 1287 |
$attachments[] = $file; |
| 1288 |
} |
| 1289 |
} elseif ($shortcode[2] === 'e2pdf-zapier' || $shortcode[2] === 'e2pdf-save') { |
| 1290 |
do_shortcode_tag($shortcode); |
| 1291 |
} |
| 1292 |
} |
| 1293 |
} |
| 1294 |
} |
| 1295 |
} elseif ($template->get('item') == 'shop_order') { |
| 1296 |
if (!isset($atts['dataset'])) { |
| 1297 |
$attachment = true; |
| 1298 |
if ($attachment) { |
| 1299 |
if (!empty($attributes)) { |
| 1300 |
$attachment = false; |
| 1301 |
foreach ($items_product as $item_id => $item) { |
| 1302 |
$product = wc_get_product($item); |
| 1303 |
if ($product) { |
| 1304 |
foreach ($attributes as $attribute_key => $attribute) { |
| 1305 |
if ($product->get_attribute($attribute_key) != $attribute) { |
| 1306 |
$attachment = true; |
| 1307 |
break; |
| 1308 |
} |
| 1309 |
} |
| 1310 |
} |
| 1311 |
} |
| 1312 |
if (!$attachment) { |
| 1313 |
foreach ($items_variation as $item_id => $item) { |
| 1314 |
$product = wc_get_product($item); |
| 1315 |
if ($product) { |
| 1316 |
foreach ($attributes as $attribute_key => $attribute) { |
| 1317 |
if ($product->get_attribute($attribute_key) == $attribute) { |
| 1318 |
$attachment = true; |
| 1319 |
break; |
| 1320 |
} |
| 1321 |
} |
| 1322 |
} |
| 1323 |
} |
| 1324 |
} |
| 1325 |
} |
| 1326 |
} |
| 1327 |
if ($attachment) { |
| 1328 |
if (isset($atts['products']) && $atts['products']) { |
| 1329 |
$attachment = false; |
| 1330 |
$products = explode(',', $atts['products']); |
| 1331 |
foreach ($products as $product_id) { |
| 1332 |
if (in_array($product_id, $items, false) || in_array($product_id, $items_variation, false)) { |
| 1333 |
$attachment = true; |
| 1334 |
break; |
| 1335 |
} |
| 1336 |
} |
| 1337 |
} |
| 1338 |
} |
| 1339 |
if ($attachment) { |
| 1340 |
if (isset($atts['categories']) && $atts['categories']) { |
| 1341 |
$attachment = false; |
| 1342 |
$categories = explode(',', $atts['categories']); |
| 1343 |
foreach ($items as $item) { |
| 1344 |
if (has_term($categories, 'product_cat', $item)) { |
| 1345 |
$attachment = true; |
| 1346 |
break; |
| 1347 |
} |
| 1348 |
} |
| 1349 |
} |
| 1350 |
} |
| 1351 |
if ($attachment) { |
| 1352 |
if (isset($atts['tags']) && $atts['tags']) { |
| 1353 |
$attachment = false; |
| 1354 |
$tags = explode(',', $atts['tags']); |
| 1355 |
foreach ($items as $item) { |
| 1356 |
if (has_term($tags, 'product_tag', $item)) { |
| 1357 |
$attachment = true; |
| 1358 |
break; |
| 1359 |
} |
| 1360 |
} |
| 1361 |
} |
| 1362 |
} |
| 1363 |
if ($attachment) { |
| 1364 |
if (!isset($atts['apply'])) { |
| 1365 |
$shortcode[3] .= ' apply="true"'; |
| 1366 |
} |
| 1367 |
if (!isset($atts['filter'])) { |
| 1368 |
$shortcode[3] .= ' filter="true"'; |
| 1369 |
} |
| 1370 |
$shortcode[3] .= ' dataset="' . $order->get_id() . '"'; |
| 1371 |
if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) { |
| 1372 |
$file = do_shortcode_tag($shortcode); |
| 1373 |
if ($file) { |
| 1374 |
$tmp = false; |
| 1375 |
if (substr($file, 0, 4) === 'tmp:') { |
| 1376 |
$file = substr($file, 4); |
| 1377 |
$tmp = true; |
| 1378 |
} |
| 1379 |
if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) { |
| 1380 |
if ($tmp) { |
| 1381 |
$this->helper->add('woocommerce_attachments', $file); |
| 1382 |
} |
| 1383 |
} else { |
| 1384 |
$this->helper->add('woocommerce_attachments', $file); |
| 1385 |
} |
| 1386 |
$attachments[] = $file; |
| 1387 |
} |
| 1388 |
} elseif ($shortcode[2] === 'e2pdf-zapier' || $shortcode[2] === 'e2pdf-save') { |
| 1389 |
do_shortcode_tag($shortcode); |
| 1390 |
} |
| 1391 |
} |
| 1392 |
} |
| 1393 |
} |
| 1394 |
} |
| 1395 |
} |
| 1396 |
} |
| 1397 |
} |
| 1398 |
} |
| 1399 |
return $attachments; |
| 1400 |
} |
| 1401 |
|
| 1402 |
public function filter_gform_merge_tag_filter($value, $merge_tag, $modifier, $field, $raw_value) { |
| 1403 |
|
| 1404 |
if ($field && $value) { |
| 1405 |
if ($field->type == 'consent') { |
| 1406 |
if (false !== strpos($modifier, 'filter') && is_callable('gw_all_fields_template')) { |
| 1407 |
$modifiers = gw_all_fields_template()->parse_modifiers($modifier); |
| 1408 |
if (isset($modifiers['filter']) && $modifiers['filter'] && !is_array($modifiers['filter'])) { |
| 1409 |
$merge_tag = $modifiers['filter']; |
| 1410 |
} |
| 1411 |
} |
| 1412 |
$mod = explode('.', $merge_tag); |
| 1413 |
if (isset($mod[1]) && $mod[1] == '1') { |
| 1414 |
$value = '1'; |
| 1415 |
} |
| 1416 |
} elseif ($field->type == 'list') { |
| 1417 |
if (false !== strpos($modifier, 'filter') && is_callable('gw_all_fields_template')) { |
| 1418 |
$modifiers = gw_all_fields_template()->parse_modifiers($modifier); |
| 1419 |
if (isset($modifiers['filter']) && $modifiers['filter'] && !is_array($modifiers['filter'])) { |
| 1420 |
if (false !== strpos($modifiers['filter'], ':')) { |
| 1421 |
$mods = explode(':', $modifiers['filter']); |
| 1422 |
$merge_tag = $mods[0]; |
| 1423 |
$modifier = $mods[1]; |
| 1424 |
} else { |
| 1425 |
$merge_tag = $modifiers['filter']; |
| 1426 |
} |
| 1427 |
} |
| 1428 |
if ($merge_tag != $field->id) { |
| 1429 |
return false; |
| 1430 |
} |
| 1431 |
} |
| 1432 |
if ($modifier && $modifier != 'text') { |
| 1433 |
$list_id = false; |
| 1434 |
$field_id = false; |
| 1435 |
if (false !== strpos($modifier, '_')) { |
| 1436 |
$mod = explode('_', $modifier); |
| 1437 |
if (isset($mod[0]) && is_numeric($mod[0])) { |
| 1438 |
$list_id = $mod[0] - 1; |
| 1439 |
} |
| 1440 |
if (isset($mod[1]) && is_numeric($mod[1])) { |
| 1441 |
$field_id = $mod[1] - 1; |
| 1442 |
} |
| 1443 |
} elseif (is_numeric($modifier)) { |
| 1444 |
$list_id = $modifier - 1; |
| 1445 |
} |
| 1446 |
if ($list_id !== false) { |
| 1447 |
$value = ''; |
| 1448 |
if (is_serialized($raw_value)) { |
| 1449 |
$list = $this->helper->load('convert')->unserialize(trim($raw_value)); |
| 1450 |
} else { |
| 1451 |
$list = $raw_value; |
| 1452 |
} |
| 1453 |
if (is_array($list)) { |
| 1454 |
if (isset($list[$list_id])) { |
| 1455 |
if ($field_id !== false) { |
| 1456 |
if (is_array($list[$list_id]) && isset(array_values($list[$list_id])[$field_id])) { |
| 1457 |
$value = array_values($list[$list_id])[$field_id]; |
| 1458 |
} |
| 1459 |
} else { |
| 1460 |
if (is_array($list[$list_id])) { |
| 1461 |
$value = implode(',', $list[$list_id]); |
| 1462 |
} else { |
| 1463 |
$value = $list[$list_id]; |
| 1464 |
} |
| 1465 |
} |
| 1466 |
} |
| 1467 |
} |
| 1468 |
} |
| 1469 |
} |
| 1470 |
} elseif ($field->type == 'name' || $field->type == 'address') { |
| 1471 |
if (false !== strpos($modifier, 'filter') && is_callable('gw_all_fields_template')) { |
| 1472 |
$modifiers = gw_all_fields_template()->parse_modifiers($modifier); |
| 1473 |
if (isset($modifiers['filter']) && $modifiers['filter'] && !is_array($modifiers['filter'])) { |
| 1474 |
if (is_array($raw_value) && isset($raw_value[$modifiers['filter']])) { |
| 1475 |
return $raw_value[$modifiers['filter']]; |
| 1476 |
} |
| 1477 |
} |
| 1478 |
} |
| 1479 |
} |
| 1480 |
} |
| 1481 |
|
| 1482 |
return $value; |
| 1483 |
} |
| 1484 |
|
| 1485 |
public function filter_woocommerce_display_product_attributes($product_attributes, $product) { |
| 1486 |
if ($product_attributes) { |
| 1487 |
foreach ($product_attributes as $product_attribute_key => $product_attribute) { |
| 1488 |
if (isset($product_attribute['value']) && $product_attribute['value'] && false !== strpos($product_attribute['value'], '[e2pdf-download')) { |
| 1489 |
$product_attributes[$product_attribute_key]['value'] = $this->filter_content(htmlspecialchars_decode($product_attribute['value']), $product->get_id()); |
| 1490 |
} |
| 1491 |
} |
| 1492 |
} |
| 1493 |
return $product_attributes; |
| 1494 |
} |
| 1495 |
|
| 1496 |
public function filter_e2pdf_model_shortcode_wc_product_get_attribute_value($product_attribute, $product) { |
| 1497 |
if ($product_attribute && false !== strpos($product_attribute, '[e2pdf-download') && $product && is_object($product) && method_exists($product, 'get_id')) { |
| 1498 |
$product_attribute = $this->filter_content(htmlspecialchars_decode($product_attribute), $product->get_id()); |
| 1499 |
} |
| 1500 |
return $product_attribute; |
| 1501 |
} |
| 1502 |
|
| 1503 |
public function filter_woocommerce_product_file_download_path($file_path, $product, $download_id) { |
| 1504 |
$file_path = $this->filter_content($file_path, $product->get_id(), true); |
| 1505 |
return $file_path; |
| 1506 |
} |
| 1507 |
|
| 1508 |
public function filter_download_urls($downloads) { |
| 1509 |
if (!empty($downloads)) { |
| 1510 |
$items = array(); |
| 1511 |
foreach ($downloads as $key => $download) { |
| 1512 |
if (isset($download['file']['file']) && $download['file']['file'] && strpos($download['file']['file'], '[e2pdf-download') !== false) { |
| 1513 |
global $wpdb; |
| 1514 |
if (isset($items[$download['download_id']])) { |
| 1515 |
$item_ids = $items[$download['download_id']]; |
| 1516 |
} else { |
| 1517 |
$item_ids = array(); |
| 1518 |
} |
| 1519 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare |
| 1520 |
$item_id = $wpdb->get_var($wpdb->prepare('SELECT `items`.`order_item_id` FROM `' . $wpdb->prefix . 'woocommerce_order_items` `items` INNER JOIN `' . $wpdb->prefix . "woocommerce_order_itemmeta` `itemmeta` ON `itemmeta`.`order_item_id` = `items`.`order_item_id` AND (`itemmeta`.`meta_key` = '_product_id' OR `itemmeta`.`meta_key` = '_variation_id' ) AND `itemmeta`.`meta_value` = %d WHERE `items`.`order_id` = %d and `items`.`order_item_type` = 'line_item' and `items`.`order_item_id` NOT IN ( '" . implode("','", $item_ids) . "' ) ORDER BY `items`.`order_item_id` ASC", $download['product_id'], $download['order_id'])); |
| 1521 |
if ($item_id) { |
| 1522 |
$downloads[$key]['download_url'] = add_query_arg( |
| 1523 |
array('item_id' => $item_id), $download['download_url'] |
| 1524 |
); |
| 1525 |
$items[$download['download_id']][] = $item_id; |
| 1526 |
} |
| 1527 |
} |
| 1528 |
} |
| 1529 |
} |
| 1530 |
return $downloads; |
| 1531 |
} |
| 1532 |
|
| 1533 |
/** |
| 1534 |
* Render value according to content |
| 1535 |
* @param string $value - Content |
| 1536 |
* @param string $type - Type of rendering value |
| 1537 |
* @param array $field - Field details |
| 1538 |
* @return string - Fully rendered value |
| 1539 |
*/ |
| 1540 |
public function render($value, $field = array(), $convert_shortcodes = true, $raw = false) { |
| 1541 |
$value = $this->render_shortcodes($value, $field); |
| 1542 |
if (!$raw) { |
| 1543 |
$value = $this->strip_shortcodes($value); |
| 1544 |
$value = $this->convert_shortcodes($value, $convert_shortcodes, isset($field['type']) && $field['type'] == 'e2pdf-html' ? true : false); |
| 1545 |
$value = $this->helper->load('field')->render_checkbox($value, $this, $field); |
| 1546 |
} |
| 1547 |
return $value; |
| 1548 |
} |
| 1549 |
|
| 1550 |
/** |
| 1551 |
* Render shortcodes which available in this extension |
| 1552 |
* @param string $value - Content |
| 1553 |
* @param string $type - Type of rendering value |
| 1554 |
* @param array $field - Field details |
| 1555 |
* @return string - Value with rendered shortcodes |
| 1556 |
*/ |
| 1557 |
public function render_shortcodes($value, $field = array()) { |
| 1558 |
$element_id = isset($field['element_id']) ? $field['element_id'] : false; |
| 1559 |
if ($this->verify()) { |
| 1560 |
if (false !== strpos($value, '[')) { |
| 1561 |
$value = $this->helper->load('field')->pre_shortcodes($value, $this, $field); |
| 1562 |
$value = $this->helper->load('field')->inner_shortcodes($value, $this, $field); |
| 1563 |
$shortcode_tags = array( |
| 1564 |
'e2pdf-wc-product', |
| 1565 |
'e2pdf-wc-order', |
| 1566 |
'e2pdf-wc-cart', |
| 1567 |
'e2pdf-content', |
| 1568 |
'e2pdf-wp', |
| 1569 |
'acf', |
| 1570 |
); |
| 1571 |
preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $value, $matches); |
| 1572 |
$tagnames = array_intersect($shortcode_tags, $matches[1]); |
| 1573 |
foreach ($matches[1] as $key => $shortcode) { |
| 1574 |
if (strpos($shortcode, ':') !== false) { |
| 1575 |
$shortcode_tags[] = $shortcode; |
| 1576 |
} |
| 1577 |
} |
| 1578 |
if (!empty($tagnames)) { |
| 1579 |
preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $value, $shortcodes); |
| 1580 |
foreach ($shortcodes[0] as $key => $shortcode_value) { |
| 1581 |
$shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key); |
| 1582 |
$atts = shortcode_parse_atts($shortcode[3]); |
| 1583 |
if ($shortcode[2] === 'e2pdf-wp') { |
| 1584 |
if (isset($atts['id']) && $atts['id'] == 'dynamic' && substr($shortcode_value, -11) === '[/e2pdf-wp]') { |
| 1585 |
if ($shortcode[5]) { |
| 1586 |
$shortcode[5] = $this->render($shortcode[5], array(), false); |
| 1587 |
} |
| 1588 |
$value = str_replace($shortcode_value, '[e2pdf-wp' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wp]', $value); |
| 1589 |
} |
| 1590 |
} elseif ($shortcode[2] == 'e2pdf-wc-product') { |
| 1591 |
switch ($this->get('item')) { |
| 1592 |
case 'product': |
| 1593 |
case 'product_variation': |
| 1594 |
if (!isset($atts['id']) && !isset($atts['index']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) { |
| 1595 |
$shortcode[3] .= ' id=' . $this->get('cached_post')->ID . ''; |
| 1596 |
} |
| 1597 |
if (!isset($atts['wc_order_id']) && $this->get('wc_order_id')) { |
| 1598 |
$shortcode[3] .= ' wc_order_id=' . $this->get('wc_order_id') . ''; |
| 1599 |
} |
| 1600 |
|
| 1601 |
if (!isset($atts['wc_product_item_id']) && $this->get('wc_product_item_id')) { |
| 1602 |
$shortcode[3] .= ' wc_product_item_id=' . $this->get('wc_product_item_id') . ''; |
| 1603 |
} |
| 1604 |
break; |
| 1605 |
case 'shop_order': |
| 1606 |
case 'shop_subscription': |
| 1607 |
if (!isset($atts['wc_order_id']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) { |
| 1608 |
$shortcode[3] .= ' wc_order_id=' . $this->get('cached_post')->ID . ''; |
| 1609 |
} |
| 1610 |
break; |
| 1611 |
case 'cart': |
| 1612 |
$shortcode[3] .= ' wc_order_id=cart'; |
| 1613 |
break; |
| 1614 |
default: |
| 1615 |
break; |
| 1616 |
} |
| 1617 |
|
| 1618 |
if (isset($atts['id']) && $atts['id'] == 'dynamic' && substr($shortcode_value, -19) === '[/e2pdf-wc-product]') { |
| 1619 |
if ($shortcode[5]) { |
| 1620 |
$shortcode[5] = $this->render($shortcode[5], array(), false); |
| 1621 |
} |
| 1622 |
$value = str_replace($shortcode_value, '[e2pdf-wc-product' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wc-product]', $value); |
| 1623 |
} else { |
| 1624 |
$value = str_replace($shortcode_value, '[e2pdf-wc-product' . $shortcode[3] . ']', $value); |
| 1625 |
} |
| 1626 |
} elseif ($shortcode[2] == 'e2pdf-wc-order') { |
| 1627 |
switch ($this->get('item')) { |
| 1628 |
case 'product': |
| 1629 |
case 'product_variation': |
| 1630 |
if (!isset($atts['id']) && $this->get('wc_order_id')) { |
| 1631 |
$shortcode[3] .= ' id=' . $this->get('wc_order_id') . ''; |
| 1632 |
} |
| 1633 |
break; |
| 1634 |
case 'shop_order': |
| 1635 |
case 'shop_subscription': |
| 1636 |
if (!isset($atts['id']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) { |
| 1637 |
$shortcode[3] .= ' id=' . $this->get('cached_post')->ID . ''; |
| 1638 |
} |
| 1639 |
break; |
| 1640 |
default: |
| 1641 |
break; |
| 1642 |
} |
| 1643 |
if (isset($atts['id']) && $atts['id'] == 'dynamic' && substr($shortcode_value, -17) === '[/e2pdf-wc-order]') { |
| 1644 |
if ($shortcode[5]) { |
| 1645 |
$shortcode[5] = $this->render($shortcode[5], array(), false); |
| 1646 |
} |
| 1647 |
$value = str_replace($shortcode_value, '[e2pdf-wc-order' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wc-order]', $value); |
| 1648 |
} else { |
| 1649 |
$value = str_replace($shortcode_value, '[e2pdf-wc-order' . $shortcode[3] . ']', $value); |
| 1650 |
} |
| 1651 |
} elseif ($shortcode[2] == 'e2pdf-wc-cart') { |
| 1652 |
if ($this->get('item') == 'cart') { |
| 1653 |
if (!isset($atts['id']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) { |
| 1654 |
$shortcode[3] .= ' id=' . $this->get('cached_post')->ID . ''; |
| 1655 |
} |
| 1656 |
$value = str_replace($shortcode_value, '[e2pdf-wc-cart' . $shortcode[3] . ']', $value); |
| 1657 |
} |
| 1658 |
} elseif ($shortcode[2] === 'acf') { |
| 1659 |
if (!isset($atts['post_id']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) { |
| 1660 |
if ($this->get('item') == 'product_variation' && isset($this->get('cached_post')->post_parent)) { |
| 1661 |
$shortcode[3] .= ' post_id=' . $this->get('cached_post')->post_parent . ''; |
| 1662 |
} else { |
| 1663 |
$shortcode[3] .= ' post_id=' . $this->get('cached_post')->ID . ''; |
| 1664 |
} |
| 1665 |
$value = str_replace($shortcode_value, '[' . $shortcode[2] . $shortcode[3] . ']', $value); |
| 1666 |
} |
| 1667 |
} |
| 1668 |
} |
| 1669 |
} |
| 1670 |
$value = $this->helper->load('field')->wrapper_shortcodes($value, $this, $field); |
| 1671 |
} |
| 1672 |
$value = $this->helper->load('field')->do_shortcodes($value, $this, $field); |
| 1673 |
|
| 1674 |
/* Process Gravity Forms Connected Entry */ |
| 1675 |
if (false !== strpos($value, '{') && class_exists('GFCommon') && class_exists('GFFormsModel')) { |
| 1676 |
if (($this->get('item') == 'product' || $this->get('item') == 'product_variation') && $this->get('wc_order_id')) { |
| 1677 |
$order = wc_get_order($this->get('wc_order_id')); |
| 1678 |
if ($order && method_exists($order, 'get_items')) { |
| 1679 |
$order_items = $order->get_items(); |
| 1680 |
$linked_entry_id = false; |
| 1681 |
if ($this->get('wc_product_item_id')) { |
| 1682 |
$item_id = $this->get('wc_product_item_id'); |
| 1683 |
if (isset($order_items[$item_id])) { |
| 1684 |
if ($linked_data = wc_get_order_item_meta($item_id, '_gravity_forms_history', true)) { |
| 1685 |
if (!empty($linked_data['_gravity_form_linked_entry_id'])) { |
| 1686 |
$linked_entry_id = $linked_data['_gravity_form_linked_entry_id']; |
| 1687 |
} |
| 1688 |
} elseif ($linked_data = wc_get_order_item_meta($item_id, 'gspc_gf_entry_ids', true)) { |
| 1689 |
if (!empty($linked_data) && isset($linked_data[0])) { |
| 1690 |
$linked_entry_id = $linked_data[0]; |
| 1691 |
} |
| 1692 |
} |
| 1693 |
} |
| 1694 |
} else { |
| 1695 |
foreach ($order_items as $item_id => $order_item) { |
| 1696 |
if ($order_item->get_product_id() == $this->get('dataset')) { |
| 1697 |
if ($linked_data = wc_get_order_item_meta($item_id, '_gravity_forms_history', true)) { |
| 1698 |
if (!empty($linked_data['_gravity_form_linked_entry_id'])) { |
| 1699 |
$linked_entry_id = $linked_data['_gravity_form_linked_entry_id']; |
| 1700 |
} |
| 1701 |
} elseif ($linked_data = wc_get_order_item_meta($item_id, 'gspc_gf_entry_ids', true)) { |
| 1702 |
if (!empty($linked_data) && isset($linked_data[0])) { |
| 1703 |
$linked_entry_id = $linked_data[0]; |
| 1704 |
} |
| 1705 |
} |
| 1706 |
} |
| 1707 |
} |
| 1708 |
} |
| 1709 |
|
| 1710 |
if ($linked_entry_id) { |
| 1711 |
$entry = GFFormsModel::get_entry($linked_entry_id); |
| 1712 |
if ($entry && isset($entry['form_id'])) { |
| 1713 |
$form = GFFormsModel::get_form_meta($entry['form_id']); |
| 1714 |
add_filter('gform_merge_tag_filter', array($this, 'filter_gform_merge_tag_filter'), 30, 5); |
| 1715 |
$value = GFCommon::replace_variables($value, $form, $entry, false, false, false, 'text'); |
| 1716 |
remove_filter('gform_merge_tag_filter', array($this, 'filter_gform_merge_tag_filter'), 30, 5); |
| 1717 |
} |
| 1718 |
} |
| 1719 |
} |
| 1720 |
} |
| 1721 |
} |
| 1722 |
|
| 1723 |
$value = $this->helper->load('field')->render( |
| 1724 |
apply_filters('e2pdf_extension_render_shortcodes_pre_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false), |
| 1725 |
$this, |
| 1726 |
$field |
| 1727 |
); |
| 1728 |
} |
| 1729 |
return apply_filters( |
| 1730 |
'e2pdf_extension_render_shortcodes_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false |
| 1731 |
); |
| 1732 |
} |
| 1733 |
|
| 1734 |
/** |
| 1735 |
* Strip unused shortcodes |
| 1736 |
* @param string $value - Content |
| 1737 |
* @return string - Value with removed unused shortcodes |
| 1738 |
*/ |
| 1739 |
public function strip_shortcodes($value) { |
| 1740 |
$value = preg_replace('~(?:\[/?)[^/\]]+/?\]~s', '', $value); |
| 1741 |
return $value; |
| 1742 |
} |
| 1743 |
|
| 1744 |
/** |
| 1745 |
* Convert "shortcodes" inside value string |
| 1746 |
* @param string $value - Value string |
| 1747 |
* @param bool $to - Convert From/To |
| 1748 |
* @return string - Converted value |
| 1749 |
*/ |
| 1750 |
public function convert_shortcodes($value, $to = false, $html = false) { |
| 1751 |
if ($value) { |
| 1752 |
if ($to) { |
| 1753 |
$value = str_replace('[', '[', $value); |
| 1754 |
if (!$html) { |
| 1755 |
$value = wp_specialchars_decode($value, ENT_QUOTES); |
| 1756 |
} |
| 1757 |
} else { |
| 1758 |
$value = str_replace('[', '[', $value); |
| 1759 |
} |
| 1760 |
} |
| 1761 |
return $value; |
| 1762 |
} |
| 1763 |
|
| 1764 |
public function auto() { |
| 1765 |
$response = array(); |
| 1766 |
$elements = array(); |
| 1767 |
|
| 1768 |
$line_height = (int) $this->get('line_height'); |
| 1769 |
|
| 1770 |
if ($this->get('item') == 'cart') { |
| 1771 |
|
| 1772 |
$elements[] = array( |
| 1773 |
'type' => 'e2pdf-html', |
| 1774 |
'block' => true, |
| 1775 |
'properties' => array( |
| 1776 |
'top' => '20', |
| 1777 |
'left' => '20', |
| 1778 |
'right' => '20', |
| 1779 |
'width' => '50%', |
| 1780 |
'height' => 'auto', |
| 1781 |
'value' => '<strong>Billing:</strong>', |
| 1782 |
), |
| 1783 |
); |
| 1784 |
|
| 1785 |
$elements[] = array( |
| 1786 |
'type' => 'e2pdf-html', |
| 1787 |
'block' => true, |
| 1788 |
'float' => true, |
| 1789 |
'properties' => array( |
| 1790 |
'top' => '20', |
| 1791 |
'left' => '20', |
| 1792 |
'right' => '20', |
| 1793 |
'width' => '50%', |
| 1794 |
'height' => 'auto', |
| 1795 |
'value' => '<strong>Shipping:</strong>', |
| 1796 |
), |
| 1797 |
); |
| 1798 |
|
| 1799 |
$elements[] = array( |
| 1800 |
'type' => 'e2pdf-html', |
| 1801 |
'block' => true, |
| 1802 |
'properties' => array( |
| 1803 |
'top' => '5', |
| 1804 |
'left' => '20', |
| 1805 |
'right' => '20', |
| 1806 |
'width' => '50%', |
| 1807 |
'height' => $line_height * 7, |
| 1808 |
'value' => '[e2pdf-wc-customer key="get_formatted_billing_address"]', |
| 1809 |
), |
| 1810 |
); |
| 1811 |
|
| 1812 |
$elements[] = array( |
| 1813 |
'type' => 'e2pdf-html', |
| 1814 |
'block' => true, |
| 1815 |
'float' => true, |
| 1816 |
'properties' => array( |
| 1817 |
'top' => '5', |
| 1818 |
'left' => '20', |
| 1819 |
'right' => '20', |
| 1820 |
'width' => '50%', |
| 1821 |
'height' => $line_height * 7, |
| 1822 |
'value' => '[e2pdf-wc-customer key="get_formatted_shipping_address"]', |
| 1823 |
), |
| 1824 |
); |
| 1825 |
|
| 1826 |
$elements[] = array( |
| 1827 |
'type' => 'e2pdf-html', |
| 1828 |
'block' => true, |
| 1829 |
'properties' => array( |
| 1830 |
'top' => '10', |
| 1831 |
'left' => '20', |
| 1832 |
'right' => '20', |
| 1833 |
'width' => '50%', |
| 1834 |
'height' => 'auto', |
| 1835 |
'value' => '<strong>E-mail:</strong>', |
| 1836 |
), |
| 1837 |
); |
| 1838 |
|
| 1839 |
$elements[] = array( |
| 1840 |
'type' => 'e2pdf-html', |
| 1841 |
'block' => true, |
| 1842 |
'float' => true, |
| 1843 |
'properties' => array( |
| 1844 |
'top' => '10', |
| 1845 |
'left' => '20', |
| 1846 |
'right' => '20', |
| 1847 |
'width' => '50%', |
| 1848 |
'height' => 'auto', |
| 1849 |
'value' => '<strong>Phone:</strong>', |
| 1850 |
), |
| 1851 |
); |
| 1852 |
|
| 1853 |
$elements[] = array( |
| 1854 |
'type' => 'e2pdf-html', |
| 1855 |
'block' => true, |
| 1856 |
'properties' => array( |
| 1857 |
'top' => '5', |
| 1858 |
'left' => '20', |
| 1859 |
'right' => '20', |
| 1860 |
'width' => '50%', |
| 1861 |
'height' => 'auto', |
| 1862 |
'value' => '[e2pdf-wc-customer key="get_billing_email"]', |
| 1863 |
), |
| 1864 |
); |
| 1865 |
|
| 1866 |
$elements[] = array( |
| 1867 |
'type' => 'e2pdf-html', |
| 1868 |
'block' => true, |
| 1869 |
'float' => true, |
| 1870 |
'properties' => array( |
| 1871 |
'top' => '5', |
| 1872 |
'left' => '20', |
| 1873 |
'right' => '20', |
| 1874 |
'width' => '50%', |
| 1875 |
'height' => 'auto', |
| 1876 |
'value' => '[e2pdf-wc-customer key="get_billing_phone"]', |
| 1877 |
), |
| 1878 |
); |
| 1879 |
|
| 1880 |
$elements[] = array( |
| 1881 |
'type' => 'e2pdf-html', |
| 1882 |
'block' => true, |
| 1883 |
'properties' => array( |
| 1884 |
'wysiwyg_disable' => '1', |
| 1885 |
'css' => 'td {' . "\r\n" |
| 1886 |
. 'text-align: center;' . "\r\n" |
| 1887 |
. 'vertical-align: top;' . "\r\n" |
| 1888 |
. '}' . "\r\n" |
| 1889 |
. '.header {' . "\r\n" |
| 1890 |
. 'background: #eeeeee;' . "\r\n" |
| 1891 |
. '}' . "\r\n" |
| 1892 |
. '.item {' . "\r\n" |
| 1893 |
. 'text-align: left;' . "\r\n" |
| 1894 |
. 'width: 40%;' . "\r\n" |
| 1895 |
. '}' . "\r\n" |
| 1896 |
. '.total-label {' . "\r\n" |
| 1897 |
. 'text-align: right;' . "\r\n" |
| 1898 |
. '}' . "\r\n" |
| 1899 |
. '.total-value {' . "\r\n" |
| 1900 |
. 'text-align: right;' . "\r\n" |
| 1901 |
. '}' . "\r\n" |
| 1902 |
. '.total-order {' . "\r\n" |
| 1903 |
. 'font-weight: bold;' . "\r\n" |
| 1904 |
. '}' . "\r\n" |
| 1905 |
. '.formatted-meta-data {' . "\r\n" |
| 1906 |
. 'color: #555555;' . "\r\n" |
| 1907 |
. 'font-size: 8px;' . "\r\n" |
| 1908 |
. '}' . "\r\n" |
| 1909 |
. '.hr {' . "\r\n" |
| 1910 |
. 'background: #eeeeee;' . "\r\n" |
| 1911 |
. '}' . "\r\n" |
| 1912 |
. '.attachment-32x32 {' . "\r\n" |
| 1913 |
. 'margin-top: 5px;' . "\r\n" |
| 1914 |
. '}' . "\r\n" |
| 1915 |
. 'ul {' . "\r\n" |
| 1916 |
. 'padding-left: 10px;' . "\r\n" |
| 1917 |
. '}' . "\r\n" |
| 1918 |
. 'li {' . "\r\n" |
| 1919 |
. 'padding-left: 5px;' . "\r\n" |
| 1920 |
. '}' . "\r\n", |
| 1921 |
'top' => '20', |
| 1922 |
'left' => '20', |
| 1923 |
'right' => '20', |
| 1924 |
'width' => '100%', |
| 1925 |
'height' => 'max', |
| 1926 |
'value' => '<table cellpadding="5">' . "\r\n" |
| 1927 |
. '<tr class="header"><td></td><td class="item">Item</td><td align="center">Quantity</td><td align="center">Unit Price</td><td align="center">Subtotal</td></tr>' . "\r\n" |
| 1928 |
. '[e2pdf-foreach shortcode="e2pdf-wc-cart" key="get_cart"]' . "\r\n" |
| 1929 |
. '<tr>' . "\r\n" |
| 1930 |
. '<td>[e2pdf-wc-product key="get_image" size="32x32" index="[e2pdf-foreach-index]" order="true" wc_filter="true"]' . "\r\n" |
| 1931 |
. '</td>' . "\r\n" |
| 1932 |
. '<td class="item">' . "\r\n" |
| 1933 |
. '[e2pdf-wc-product key="get_name" index="[e2pdf-foreach-index]" order="true" wc_filter="true"]' . "\r\n" |
| 1934 |
. '[e2pdf-foreach-1 shortcode="e2pdf-wc-product" key="get_formatted_meta_data" index="[e2pdf-foreach-index]" order="true"]' . "\r\n" |
| 1935 |
. '<div class="formatted-meta-data">[e2pdf-wc-product key="get_formatted_meta_data" index="[e2pdf-foreach-index]" path="[e2pdf-foreach-key-1].display_key"]: [e2pdf-wc-product key="get_formatted_meta_data" index="[e2pdf-foreach-index]" path="[e2pdf-foreach-key-1].display_value"]</div>' . "\r\n" |
| 1936 |
. '[/e2pdf-foreach-1]' . "\r\n" |
| 1937 |
. '</td>' . "\r\n" |
| 1938 |
. '<td align="center">[e2pdf-wc-product key="get_quantity" index="[e2pdf-foreach-index]" order="true"]</td>' . "\r\n" |
| 1939 |
. '<td align="center">[e2pdf-wc-product key="get_product_price" index="[e2pdf-foreach-index]" order="true" wc_filter="true"]</td>' . "\r\n" |
| 1940 |
. '<td align="center">[e2pdf-wc-product key="get_subtotal" index="[e2pdf-foreach-index]" order="true" wc_filter="true"]</td>' . "\r\n" |
| 1941 |
. '</tr>' . "\r\n" |
| 1942 |
. '[/e2pdf-foreach]' . "\r\n" |
| 1943 |
. '<tr><td colspan="5"><hr class="hr"></td></tr>' . "\r\n" |
| 1944 |
. '[e2pdf-foreach shortcode="e2pdf-wc-cart" key="get_formatted_cart_totals"]' . "\r\n" |
| 1945 |
. '<tr><td colspan="3" class="total-label">[e2pdf-wc-cart key="get_formatted_cart_totals" path="[e2pdf-foreach-key].label"]:</td><td colspan="2" class="total-value">[e2pdf-wc-cart key="get_formatted_cart_totals" path="[e2pdf-foreach-key].value"]</td></tr>' . "\r\n" |
| 1946 |
. '[/e2pdf-foreach]' . "\r\n" |
| 1947 |
. '</table>' . "\r\n", |
| 1948 |
), |
| 1949 |
); |
| 1950 |
} elseif ($this->get('item') == 'shop_order' || $this->get('item') == 'shop_subscription') { |
| 1951 |
$elements[] = array( |
| 1952 |
'type' => 'e2pdf-html', |
| 1953 |
'block' => true, |
| 1954 |
'properties' => array( |
| 1955 |
'top' => '20', |
| 1956 |
'left' => '20', |
| 1957 |
'right' => '20', |
| 1958 |
'width' => '100%', |
| 1959 |
'height' => 'auto', |
| 1960 |
'value' => '<h2>[e2pdf-wc-order key="get_order_number"]</h2>' . "\r\n", |
| 1961 |
), |
| 1962 |
); |
| 1963 |
|
| 1964 |
$elements[] = array( |
| 1965 |
'type' => 'e2pdf-html', |
| 1966 |
'block' => true, |
| 1967 |
'properties' => array( |
| 1968 |
'top' => '5', |
| 1969 |
'left' => '20', |
| 1970 |
'right' => '20', |
| 1971 |
'width' => '100%', |
| 1972 |
'height' => 'auto', |
| 1973 |
'value' => 'Payment via [e2pdf-wc-order key="get_payment_method_title"]' . "\r\n", |
| 1974 |
), |
| 1975 |
); |
| 1976 |
|
| 1977 |
$elements[] = array( |
| 1978 |
'type' => 'e2pdf-html', |
| 1979 |
'block' => true, |
| 1980 |
'properties' => array( |
| 1981 |
'top' => '20', |
| 1982 |
'left' => '20', |
| 1983 |
'right' => '20', |
| 1984 |
'width' => '100%', |
| 1985 |
'height' => $line_height * 3, |
| 1986 |
'value' => 'Order ID: [e2pdf-wc-order key="get_id"]<br>' |
| 1987 |
. 'Date Created: [e2pdf-wc-order key="get_date_created"]<br>' . "\r\n" |
| 1988 |
. 'Status: [e2pdf-wc-order key="get_status" wc_get_order_status_name="true"]' . "\r\n", |
| 1989 |
), |
| 1990 |
); |
| 1991 |
|
| 1992 |
$elements[] = array( |
| 1993 |
'type' => 'e2pdf-html', |
| 1994 |
'block' => true, |
| 1995 |
'properties' => array( |
| 1996 |
'top' => '20', |
| 1997 |
'left' => '20', |
| 1998 |
'right' => '20', |
| 1999 |
'width' => '50%', |
| 2000 |
'height' => 'auto', |
| 2001 |
'value' => '<strong>Billing:</strong>', |
| 2002 |
), |
| 2003 |
); |
| 2004 |
|
| 2005 |
$elements[] = array( |
| 2006 |
'type' => 'e2pdf-html', |
| 2007 |
'block' => true, |
| 2008 |
'float' => true, |
| 2009 |
'properties' => array( |
| 2010 |
'top' => '20', |
| 2011 |
'left' => '20', |
| 2012 |
'right' => '20', |
| 2013 |
'width' => '50%', |
| 2014 |
'height' => 'auto', |
| 2015 |
'value' => '<strong>Shipping:</strong>', |
| 2016 |
), |
| 2017 |
); |
| 2018 |
|
| 2019 |
$elements[] = array( |
| 2020 |
'type' => 'e2pdf-html', |
| 2021 |
'block' => true, |
| 2022 |
'properties' => array( |
| 2023 |
'top' => '5', |
| 2024 |
'left' => '20', |
| 2025 |
'right' => '20', |
| 2026 |
'width' => '50%', |
| 2027 |
'height' => $line_height * 7, |
| 2028 |
'value' => '[e2pdf-wc-order key="get_formatted_billing_address"]', |
| 2029 |
), |
| 2030 |
); |
| 2031 |
|
| 2032 |
$elements[] = array( |
| 2033 |
'type' => 'e2pdf-html', |
| 2034 |
'block' => true, |
| 2035 |
'float' => true, |
| 2036 |
'properties' => array( |
| 2037 |
'top' => '5', |
| 2038 |
'left' => '20', |
| 2039 |
'right' => '20', |
| 2040 |
'width' => '50%', |
| 2041 |
'height' => $line_height * 7, |
| 2042 |
'value' => '[e2pdf-wc-order key="get_formatted_shipping_address"]', |
| 2043 |
), |
| 2044 |
); |
| 2045 |
|
| 2046 |
$elements[] = array( |
| 2047 |
'type' => 'e2pdf-html', |
| 2048 |
'block' => true, |
| 2049 |
'properties' => array( |
| 2050 |
'top' => '10', |
| 2051 |
'left' => '20', |
| 2052 |
'right' => '20', |
| 2053 |
'width' => '50%', |
| 2054 |
'height' => 'auto', |
| 2055 |
'value' => '<strong>E-mail:</strong>', |
| 2056 |
), |
| 2057 |
); |
| 2058 |
|
| 2059 |
$elements[] = array( |
| 2060 |
'type' => 'e2pdf-html', |
| 2061 |
'block' => true, |
| 2062 |
'float' => true, |
| 2063 |
'properties' => array( |
| 2064 |
'top' => '10', |
| 2065 |
'left' => '20', |
| 2066 |
'right' => '20', |
| 2067 |
'width' => '50%', |
| 2068 |
'height' => 'auto', |
| 2069 |
'value' => '<strong>Phone:</strong>', |
| 2070 |
), |
| 2071 |
); |
| 2072 |
|
| 2073 |
$elements[] = array( |
| 2074 |
'type' => 'e2pdf-html', |
| 2075 |
'block' => true, |
| 2076 |
'properties' => array( |
| 2077 |
'top' => '5', |
| 2078 |
'left' => '20', |
| 2079 |
'right' => '20', |
| 2080 |
'width' => '50%', |
| 2081 |
'height' => 'auto', |
| 2082 |
'value' => '[e2pdf-wc-order key="get_billing_email"]', |
| 2083 |
), |
| 2084 |
); |
| 2085 |
|
| 2086 |
$elements[] = array( |
| 2087 |
'type' => 'e2pdf-html', |
| 2088 |
'block' => true, |
| 2089 |
'float' => true, |
| 2090 |
'properties' => array( |
| 2091 |
'top' => '5', |
| 2092 |
'left' => '20', |
| 2093 |
'right' => '20', |
| 2094 |
'width' => '50%', |
| 2095 |
'height' => 'auto', |
| 2096 |
'value' => '[e2pdf-wc-order key="get_billing_phone"]', |
| 2097 |
), |
| 2098 |
); |
| 2099 |
|
| 2100 |
$elements[] = array( |
| 2101 |
'type' => 'e2pdf-html', |
| 2102 |
'block' => true, |
| 2103 |
'properties' => array( |
| 2104 |
'wysiwyg_disable' => '1', |
| 2105 |
'css' => 'td {' . "\r\n" |
| 2106 |
. 'text-align: center;' . "\r\n" |
| 2107 |
. 'vertical-align: top;' . "\r\n" |
| 2108 |
. '}' . "\r\n" |
| 2109 |
. '.header {' . "\r\n" |
| 2110 |
. 'background: #eeeeee;' . "\r\n" |
| 2111 |
. '}' . "\r\n" |
| 2112 |
. '.item {' . "\r\n" |
| 2113 |
. 'text-align: left;' . "\r\n" |
| 2114 |
. 'width: 40%;' . "\r\n" |
| 2115 |
. '}' . "\r\n" |
| 2116 |
. '.total-label {' . "\r\n" |
| 2117 |
. 'text-align: right;' . "\r\n" |
| 2118 |
. '}' . "\r\n" |
| 2119 |
. '.total-value {' . "\r\n" |
| 2120 |
. 'text-align: right;' . "\r\n" |
| 2121 |
. '}' . "\r\n" |
| 2122 |
. '.total-order {' . "\r\n" |
| 2123 |
. 'font-weight: bold;' . "\r\n" |
| 2124 |
. '}' . "\r\n" |
| 2125 |
. '.formatted-meta-data {' . "\r\n" |
| 2126 |
. 'color: #555555;' . "\r\n" |
| 2127 |
. 'font-size: 8px;' . "\r\n" |
| 2128 |
. '}' . "\r\n" |
| 2129 |
. '.hr {' . "\r\n" |
| 2130 |
. 'background-color: #eeeeee;' . "\r\n" |
| 2131 |
. '}' . "\r\n" |
| 2132 |
. '.attachment-32x32 {' . "\r\n" |
| 2133 |
. 'margin-top: 5px;' . "\r\n" |
| 2134 |
. '}' . "\r\n" |
| 2135 |
. 'ul {' . "\r\n" |
| 2136 |
. 'padding-left: 10px;' . "\r\n" |
| 2137 |
. '}' . "\r\n" |
| 2138 |
. 'li {' . "\r\n" |
| 2139 |
. 'padding-left: 5px;' . "\r\n" |
| 2140 |
. '}' . "\r\n", |
| 2141 |
'top' => '20', |
| 2142 |
'left' => '20', |
| 2143 |
'right' => '20', |
| 2144 |
'width' => '100%', |
| 2145 |
'height' => 'max', |
| 2146 |
'value' => '<table cellpadding="5">' . "\r\n" |
| 2147 |
. '<tr class="header"><td class="item">Item</td><td align="center">Quantity</td><td align="center">Unit Price</td><td align="center">Subtotal</td><td align="center">Total</td></tr>' . "\r\n" |
| 2148 |
. '[e2pdf-foreach shortcode="e2pdf-wc-order" key="get_items"]' . "\r\n" |
| 2149 |
. '<tr>' . "\r\n" |
| 2150 |
. '<td class="item">' . "\r\n" |
| 2151 |
. '[e2pdf-wc-product key="get_name" index="[e2pdf-foreach-index]" order="true"]' . "\r\n" |
| 2152 |
. '[e2pdf-foreach-1 shortcode="e2pdf-wc-product" key="get_formatted_meta_data" index="[e2pdf-foreach-index]"]' . "\r\n" |
| 2153 |
. '<div class="formatted-meta-data">[e2pdf-wc-product key="get_formatted_meta_data" index="[e2pdf-foreach-index]" path="[e2pdf-foreach-key-1].display_key"]: [e2pdf-wc-product key="get_formatted_meta_data" index="[e2pdf-foreach-index]" path="[e2pdf-foreach-key-1].display_value"]</div>' . "\r\n" |
| 2154 |
. '[/e2pdf-foreach-1]' . "\r\n" |
| 2155 |
. '</td>' . "\r\n" |
| 2156 |
. '<td align="center">[e2pdf-wc-product key="get_quantity" index="[e2pdf-foreach-index]" order="true"]</td>' . "\r\n" |
| 2157 |
. '<td align="center">[e2pdf-wc-product key="get_item_subtotal" index="[e2pdf-foreach-index]" order="true" wc_price="true"]</td>' . "\r\n" |
| 2158 |
. '<td align="center">[e2pdf-wc-product key="get_subtotal" index="[e2pdf-foreach-index]" order="true" wc_price="true"]</td>' . "\r\n" |
| 2159 |
. '<td align="center">[e2pdf-wc-product key="get_total" index="[e2pdf-foreach-index]" order="true" wc_price="true"]</td>' . "\r\n" |
| 2160 |
. '</tr>' . "\r\n" |
| 2161 |
. '[/e2pdf-foreach]' . "\r\n" |
| 2162 |
. '<tr><td colspan="5"><hr class="hr"></td></tr>' . "\r\n" |
| 2163 |
. '[e2pdf-foreach shortcode="e2pdf-wc-order" key="get_order_item_totals"]' . "\r\n" |
| 2164 |
. '<tr>' . "\r\n" |
| 2165 |
. '<td colspan="3" class="total-label">[e2pdf-wc-order key="get_order_item_totals" path="[e2pdf-foreach-key].label"]</td>' . "\r\n" |
| 2166 |
. '<td colspan="2" class="total-value">[e2pdf-wc-order key="get_order_item_totals" path="[e2pdf-foreach-key].value"]</td>' . "\r\n" |
| 2167 |
. '</tr>' . "\r\n" |
| 2168 |
. '[/e2pdf-foreach]' . "\r\n" |
| 2169 |
. '</table>' . "\r\n", |
| 2170 |
), |
| 2171 |
); |
| 2172 |
} elseif ($this->get('item') == 'product' || $this->get('item') == 'product_variation') { |
| 2173 |
|
| 2174 |
$elements[] = array( |
| 2175 |
'type' => 'e2pdf-html', |
| 2176 |
'block' => true, |
| 2177 |
'float' => true, |
| 2178 |
'properties' => array( |
| 2179 |
'top' => '20', |
| 2180 |
'left' => '20', |
| 2181 |
'right' => '20', |
| 2182 |
'width' => '100%', |
| 2183 |
'height' => 'auto', |
| 2184 |
'value' => '<hr>', |
| 2185 |
), |
| 2186 |
); |
| 2187 |
|
| 2188 |
$elements[] = array( |
| 2189 |
'type' => 'e2pdf-image', |
| 2190 |
'properties' => array( |
| 2191 |
'top' => '20', |
| 2192 |
'width' => '110', |
| 2193 |
'height' => '110', |
| 2194 |
'value' => '[e2pdf-wc-product key="get_image"]', |
| 2195 |
'dimension' => '1', |
| 2196 |
'vertical' => 'top', |
| 2197 |
'horizontal' => 'center', |
| 2198 |
), |
| 2199 |
); |
| 2200 |
|
| 2201 |
if ($this->get('item') == 'product_variation') { |
| 2202 |
|
| 2203 |
$elements[] = array( |
| 2204 |
'type' => 'e2pdf-html', |
| 2205 |
'float' => true, |
| 2206 |
'properties' => array( |
| 2207 |
'left' => '20', |
| 2208 |
'right' => '110', |
| 2209 |
'height' => '110', |
| 2210 |
'width' => '100%', |
| 2211 |
'value' => '<h2>[e2pdf-wc-product key="get_name"]</h2><br>' . "\r\n" |
| 2212 |
. '<div>Price: [e2pdf-wc-product key="get_price" wc_price="true"]</div>' . "\r\n", |
| 2213 |
), |
| 2214 |
); |
| 2215 |
|
| 2216 |
$elements[] = array( |
| 2217 |
'type' => 'e2pdf-html', |
| 2218 |
'block' => true, |
| 2219 |
'float' => true, |
| 2220 |
'properties' => array( |
| 2221 |
'top' => '20', |
| 2222 |
'left' => '20', |
| 2223 |
'right' => '20', |
| 2224 |
'width' => '100%', |
| 2225 |
'height' => 'max', |
| 2226 |
'wysiwyg_disable' => '1', |
| 2227 |
'value' => |
| 2228 |
'<table cellpadding="5">' . "\r\n" |
| 2229 |
. '<tr><td colspan="2"><b>Additional Information:</b></td></tr>' . "\r\n" |
| 2230 |
. '[e2pdf-foreach shortcode="e2pdf-wc-product" key="get_attributes" wc_filter="true"]' . "\r\n" |
| 2231 |
. '<tr>' . "\r\n" |
| 2232 |
. '<td>[e2pdf-wc-product key="get_attributes" path="[e2pdf-foreach-key].label" wc_filter="true"]:</td>' . "\r\n" |
| 2233 |
. '<td>[e2pdf-wc-product key="get_attributes" path="[e2pdf-foreach-key].value" wc_filter="true"]</td>' . "\r\n" |
| 2234 |
. '</tr>' . "\r\n" |
| 2235 |
. '[/e2pdf-foreach]' . "\r\n" |
| 2236 |
. '</table>' . "\r\n" |
| 2237 |
. '<table cellpadding="5">' . "\r\n" |
| 2238 |
. '<tr><td><b>Description</b></td></tr>' . "\r\n" |
| 2239 |
. '<tr><td>[e2pdf-wc-product key="get_description" wc_format_content="true"]</td></tr>' . "\r\n" |
| 2240 |
. '</table>' . "\r\n", |
| 2241 |
), |
| 2242 |
); |
| 2243 |
} else { |
| 2244 |
|
| 2245 |
$elements[] = array( |
| 2246 |
'type' => 'e2pdf-html', |
| 2247 |
'float' => true, |
| 2248 |
'properties' => array( |
| 2249 |
'left' => '20', |
| 2250 |
'right' => '110', |
| 2251 |
'height' => '110', |
| 2252 |
'width' => '100%', |
| 2253 |
'value' => '<h2>[e2pdf-wc-product key="get_name"]</h2><br>' . "\r\n" |
| 2254 |
. '<div>Price: [e2pdf-wc-product key="get_price" wc_price="true"]</div>' . "\r\n", |
| 2255 |
), |
| 2256 |
); |
| 2257 |
|
| 2258 |
$elements[] = array( |
| 2259 |
'type' => 'e2pdf-html', |
| 2260 |
'block' => true, |
| 2261 |
'float' => true, |
| 2262 |
'properties' => array( |
| 2263 |
'top' => '20', |
| 2264 |
'left' => '20', |
| 2265 |
'right' => '20', |
| 2266 |
'width' => '100%', |
| 2267 |
'height' => 'max', |
| 2268 |
'wysiwyg_disable' => '1', |
| 2269 |
'value' => |
| 2270 |
'<table cellpadding="5">' . "\r\n" |
| 2271 |
. '<tr><td colspan="2"><b>Additional Information:</b></td></tr>' . "\r\n" |
| 2272 |
. '[e2pdf-foreach shortcode="e2pdf-wc-product" key="get_attributes" wc_filter="true"]' . "\r\n" |
| 2273 |
. '<tr>' . "\r\n" |
| 2274 |
. '<td>[e2pdf-wc-product key="get_attributes" path="[e2pdf-foreach-key].label" wc_filter="true"]:</td>' . "\r\n" |
| 2275 |
. '<td>[e2pdf-wc-product key="get_attributes" path="[e2pdf-foreach-key].value" wc_filter="true"]</td>' . "\r\n" |
| 2276 |
. '</tr>' . "\r\n" |
| 2277 |
. '[/e2pdf-foreach]' . "\r\n" |
| 2278 |
. '</table>' . "\r\n" |
| 2279 |
. '<table cellpadding="5">' . "\r\n" |
| 2280 |
. '<tr><td><b>Short Description</b></td></tr>' . "\r\n" |
| 2281 |
. '<tr><td>[e2pdf-wc-product key="get_short_description" wc_format_content="true"]</td></tr>' . "\r\n" |
| 2282 |
. '</table>' . "\r\n", |
| 2283 |
), |
| 2284 |
); |
| 2285 |
} |
| 2286 |
} |
| 2287 |
|
| 2288 |
$response['page'] = array( |
| 2289 |
'bottom' => '20', |
| 2290 |
'top' => '20', |
| 2291 |
'left' => '20', |
| 2292 |
'right' => '20', |
| 2293 |
); |
| 2294 |
|
| 2295 |
$response['elements'] = $elements; |
| 2296 |
return $response; |
| 2297 |
} |
| 2298 |
|
| 2299 |
public function filter_content_custom($content) { |
| 2300 |
$content = $this->filter_content($content); |
| 2301 |
return $content; |
| 2302 |
} |
| 2303 |
|
| 2304 |
public function filter_the_content($content, $post_id = false) { |
| 2305 |
$content = $this->filter_content($content, $post_id); |
| 2306 |
return $content; |
| 2307 |
} |
| 2308 |
|
| 2309 |
/** |
| 2310 |
* Search and update shortcodes for this extension inside content |
| 2311 |
* Auto set of dataset id |
| 2312 |
* @param string $content - Content |
| 2313 |
* @param string $post_id - Custom Post ID |
| 2314 |
* @return string - Content with updated shortcodes |
| 2315 |
*/ |
| 2316 |
public function filter_content($content, $post_id = false, $download = false, $wp_reset_postdata = true) { |
| 2317 |
global $post; |
| 2318 |
if (!is_string($content) || false === strpos($content, '[')) { |
| 2319 |
return $content; |
| 2320 |
} |
| 2321 |
$shortcode_tags = array( |
| 2322 |
'e2pdf-download', |
| 2323 |
'e2pdf-save', |
| 2324 |
'e2pdf-view', |
| 2325 |
'e2pdf-adobesign', |
| 2326 |
'e2pdf-zapier', |
| 2327 |
); |
| 2328 |
preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches); |
| 2329 |
$tagnames = array_intersect($shortcode_tags, $matches[1]); |
| 2330 |
if (!empty($tagnames)) { |
| 2331 |
preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes); |
| 2332 |
foreach ($shortcodes[0] as $key => $shortcode_value) { |
| 2333 |
$shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key); |
| 2334 |
$atts = shortcode_parse_atts($shortcode[3]); |
| 2335 |
if (isset($atts['wp_reset_postdata'])) { |
| 2336 |
if ($atts['wp_reset_postdata'] == 'true') { |
| 2337 |
$wp_reset_postdata = true; |
| 2338 |
} else { |
| 2339 |
$wp_reset_postdata = false; |
| 2340 |
} |
| 2341 |
} |
| 2342 |
if ($wp_reset_postdata) { |
| 2343 |
wp_reset_postdata(); |
| 2344 |
} |
| 2345 |
if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf |
| 2346 |
} else { |
| 2347 |
if (isset($atts['id'])) { |
| 2348 |
$template = new Model_E2pdf_Template(); |
| 2349 |
$template->load($atts['id']); |
| 2350 |
if ($template->get('extension') === 'wordpress' || $template->get('extension') === 'jetformbuilder') { // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled |
| 2351 |
if (!$download) { |
| 2352 |
continue; |
| 2353 |
} |
| 2354 |
} elseif ($template->get('extension') === 'gravity') { |
| 2355 |
if (!isset($atts['dataset'])) { |
| 2356 |
if (function_exists('wc_get_order') && isset($_GET['order'])) { |
| 2357 |
$order_id = wc_get_order_id_by_order_key(wc_clean(wp_unslash($_GET['order']))); |
| 2358 |
if ($order_id) { |
| 2359 |
$item_id = isset($_GET['item_id']) && $_GET['item_id'] ? wc_clean(wp_unslash($_GET['item_id'])) : false; |
| 2360 |
if ($item_id) { |
| 2361 |
$order = wc_get_order($order_id); |
| 2362 |
if ($order && method_exists($order, 'get_items')) { |
| 2363 |
$order_items = $order->get_items(); |
| 2364 |
if (isset($order_items[$item_id])) { |
| 2365 |
$linked_entry_id = false; |
| 2366 |
if ($linked_data = wc_get_order_item_meta($item_id, '_gravity_forms_history', true)) { |
| 2367 |
if (!empty($linked_data['_gravity_form_linked_entry_id'])) { |
| 2368 |
$linked_entry_id = $linked_data['_gravity_form_linked_entry_id']; |
| 2369 |
} |
| 2370 |
} elseif ($linked_data = wc_get_order_item_meta($item_id, 'gspc_gf_entry_ids', true)) { |
| 2371 |
if (!empty($linked_data) && isset($linked_data[0])) { |
| 2372 |
$linked_entry_id = $linked_data[0]; |
| 2373 |
} |
| 2374 |
} |
| 2375 |
if ($linked_entry_id) { |
| 2376 |
$atts['dataset'] = $linked_entry_id; |
| 2377 |
$shortcode[3] .= ' dataset="' . $linked_entry_id . '"'; |
| 2378 |
} |
| 2379 |
} |
| 2380 |
} |
| 2381 |
} |
| 2382 |
} |
| 2383 |
} |
| 2384 |
} |
| 2385 |
} elseif ($template->get('extension') === 'formidable') { |
| 2386 |
if (!isset($atts['dataset'])) { |
| 2387 |
if (function_exists('wc_get_order') && isset($_GET['order'])) { |
| 2388 |
$order_id = wc_get_order_id_by_order_key(wc_clean(wp_unslash($_GET['order']))); |
| 2389 |
if ($order_id) { |
| 2390 |
$item_id = isset($_GET['item_id']) && $_GET['item_id'] ? wc_clean(wp_unslash($_GET['item_id'])) : false; |
| 2391 |
if ($item_id) { |
| 2392 |
$order = wc_get_order($order_id); |
| 2393 |
if ($order && method_exists($order, 'get_items')) { |
| 2394 |
$order_items = $order->get_items(); |
| 2395 |
if (isset($order_items[$item_id])) { |
| 2396 |
$_formidable_form_data = wc_get_order_item_meta($item_id, '_formidable_form_data', true); |
| 2397 |
if ($_formidable_form_data) { |
| 2398 |
$atts['dataset'] = $_formidable_form_data; |
| 2399 |
$shortcode[3] .= ' dataset="' . $_formidable_form_data . '"'; |
| 2400 |
} |
| 2401 |
} |
| 2402 |
} |
| 2403 |
} |
| 2404 |
} |
| 2405 |
} |
| 2406 |
} |
| 2407 |
} elseif ($template->get('extension') === 'woocommerce') { |
| 2408 |
if (!isset($atts['dataset']) && ($template->get('item') == 'shop_order' || $template->get('item') == 'shop_subscription') && function_exists('wc_get_order') && isset($_GET['order'])) { |
| 2409 |
$order_id = wc_get_order_id_by_order_key(wc_clean(wp_unslash($_GET['order']))); |
| 2410 |
|
| 2411 |
if (function_exists('wcs_get_subscription') && $template->get('item') == 'shop_order' && get_post_type($order_id) == 'shop_subscription') { |
| 2412 |
$subscription = wcs_get_subscription($order_id); |
| 2413 |
if ($subscription) { |
| 2414 |
$subscription_order = $subscription->get_parent(); |
| 2415 |
if ($subscription_order) { |
| 2416 |
$order_id = $subscription_order->get_id(); |
| 2417 |
} |
| 2418 |
} |
| 2419 |
} |
| 2420 |
|
| 2421 |
if ($order_id) { |
| 2422 |
$atts['dataset'] = $order_id; |
| 2423 |
$shortcode[3] .= ' dataset="' . $order_id . '"'; |
| 2424 |
} |
| 2425 |
} |
| 2426 |
if (!isset($atts['dataset']) && ($post_id || isset($post->ID))) { |
| 2427 |
$dataset_id = $post_id ? $post_id : $post->ID; |
| 2428 |
$atts['dataset'] = $dataset_id; |
| 2429 |
$shortcode[3] .= ' dataset="' . $dataset_id . '"'; |
| 2430 |
} |
| 2431 |
if (($template->get('item') == 'product' || $template->get('item') == 'product_variation') && function_exists('wc_get_order') && isset($_GET['order'])) { |
| 2432 |
$order_id = wc_get_order_id_by_order_key(wc_clean(wp_unslash($_GET['order']))); |
| 2433 |
if ($order_id) { |
| 2434 |
$atts['wc_order_id'] = $order_id; |
| 2435 |
$shortcode[3] .= ' wc_order_id="' . $order_id . '"'; |
| 2436 |
|
| 2437 |
$item_id = isset($_GET['item_id']) && $_GET['item_id'] ? wc_clean(wp_unslash($_GET['item_id'])) : false; |
| 2438 |
if ($item_id) { |
| 2439 |
$order = wc_get_order($order_id); |
| 2440 |
if ($order && method_exists($order, 'get_items')) { |
| 2441 |
$order_items = $order->get_items(); |
| 2442 |
if (isset($order_items[$item_id])) { |
| 2443 |
$atts['wc_product_item_id'] = $item_id; |
| 2444 |
$shortcode[3] .= ' wc_product_item_id="' . $item_id . '"'; |
| 2445 |
} |
| 2446 |
} |
| 2447 |
} |
| 2448 |
} |
| 2449 |
} |
| 2450 |
} |
| 2451 |
} |
| 2452 |
if (!isset($atts['apply'])) { |
| 2453 |
$shortcode[3] .= ' apply="true"'; |
| 2454 |
} |
| 2455 |
if (!isset($atts['filter'])) { |
| 2456 |
$shortcode[3] .= ' filter="true"'; |
| 2457 |
} |
| 2458 |
if ($download) { |
| 2459 |
$site_url = str_replace(array('http:', 'https:'), array('', ''), $this->helper->load('translator')->translate_url($this->helper->get_frontend_site_url())); |
| 2460 |
$shortcode[3] .= ' output="url" site_url="' . $site_url . '" esc_url_raw="true" wc_product_download="true"'; |
| 2461 |
} |
| 2462 |
$content = str_replace($shortcode_value, do_shortcode_tag($shortcode), $content); |
| 2463 |
} |
| 2464 |
} |
| 2465 |
} |
| 2466 |
return $content; |
| 2467 |
} |
| 2468 |
|
| 2469 |
public function filter_woocommerce_product_downloads_approved_directory_validation_for_shortcodes($enabled) { |
| 2470 |
if (get_option('wc_downloads_approved_directories_mode') === 'enabled') { |
| 2471 |
return false; |
| 2472 |
} |
| 2473 |
return $enabled; |
| 2474 |
} |
| 2475 |
|
| 2476 |
/** |
| 2477 |
* Verify if item and dataset exists |
| 2478 |
* @return bool - item and dataset exists |
| 2479 |
*/ |
| 2480 |
public function verify() { |
| 2481 |
if ( |
| 2482 |
$this->get('item') && $this->get('cached_post') && |
| 2483 |
( |
| 2484 |
($this->get('item') == get_post_type($this->get('cached_post'))) || |
| 2485 |
($this->get('item') == 'cart' && $this->get('dataset') == wc_get_page_id('cart')) || |
| 2486 |
($this->get('item') == 'shop_order' && get_post_type($this->get('cached_post')) == 'shop_order_placehold') |
| 2487 |
) |
| 2488 |
) { |
| 2489 |
return true; |
| 2490 |
} |
| 2491 |
return false; |
| 2492 |
} |
| 2493 |
|
| 2494 |
/** |
| 2495 |
* Init Visual Mapper data |
| 2496 |
* @return bool|string - HTML data source for Visual Mapper |
| 2497 |
*/ |
| 2498 |
public function visual_mapper() { |
| 2499 |
|
| 2500 |
$vc = ''; |
| 2501 |
|
| 2502 |
if ($this->get('item') == 'cart') { |
| 2503 |
$vc .= '<h3 class="e2pdf-plr5">Cart</h3>'; |
| 2504 |
$vc .= '<div class="e2pdf-grid">'; |
| 2505 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart', 'e2pdf-wc-cart key="cart"') . '</div>'; |
| 2506 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Products', 'e2pdf-wc-cart key="get_cart"') . '</div>'; |
| 2507 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Applied Coupons', 'e2pdf-wc-cart key="get_applied_coupons"') . '</div>'; |
| 2508 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Total', 'e2pdf-wc-cart key="get_cart_total"') . '</div>'; |
| 2509 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Subtotal', 'e2pdf-wc-cart key="get_cart_subtotal"') . '</div>'; |
| 2510 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Tax', 'e2pdf-wc-cart key="get_cart_tax"') . '</div>'; |
| 2511 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Hash', 'e2pdf-wc-cart key="get_cart_hash"') . '</div>'; |
| 2512 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Contents Total', 'e2pdf-wc-cart key="get_cart_contents_total"') . '</div>'; |
| 2513 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Contents Tax', 'e2pdf-wc-cart key="get_cart_contents_tax"') . '</div>'; |
| 2514 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Contents Taxes', 'e2pdf-wc-cart key="get_cart_contents_taxes"') . '</div>'; |
| 2515 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Contents Count', 'e2pdf-wc-cart key="get_cart_contents_count"') . '</div>'; |
| 2516 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Contents Weight', 'e2pdf-wc-cart key="get_cart_contents_weight"') . '</div>'; |
| 2517 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Item Quantities', 'e2pdf-wc-cart key="get_cart_item_quantities"') . '</div>'; |
| 2518 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Item Tax Classes', 'e2pdf-wc-cart key="get_cart_item_tax_classes"') . '</div>'; |
| 2519 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Item Tax Classes For Shipping', 'e2pdf-wc-cart key="get_cart_item_tax_classes_for_shipping"') . '</div>'; |
| 2520 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Shipping Total', 'e2pdf-wc-cart key="get_cart_shipping_total"') . '</div>'; |
| 2521 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Coupon Discount Totals', 'e2pdf-wc-cart key="get_coupon_discount_totals"') . '</div>'; |
| 2522 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Coupon Discount Tax Totals', 'e2pdf-wc-cart key="get_coupon_discount_tax_totals"') . '</div>'; |
| 2523 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Totals', 'e2pdf-wc-cart key="get_totals"') . '</div>'; |
| 2524 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total', 'e2pdf-wc-cart key="get_total"') . '</div>'; |
| 2525 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Tax', 'e2pdf-wc-cart key="get_total_tax"') . '</div>'; |
| 2526 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Ex Tax', 'e2pdf-wc-cart key="get_total_ex_tax"') . '</div>'; |
| 2527 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Discount', 'e2pdf-wc-cart key="get_total_discount"') . '</div>'; |
| 2528 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Subtotal', 'e2pdf-wc-cart key="get_subtotal"') . '</div>'; |
| 2529 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Subtotal Tax', 'e2pdf-wc-cart key="get_subtotal_tax"') . '</div>'; |
| 2530 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Discount Total', 'e2pdf-wc-cart key="get_discount_total"') . '</div>'; |
| 2531 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Discount Tax', 'e2pdf-wc-cart key="get_discount_tax"') . '</div>'; |
| 2532 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Total', 'e2pdf-wc-cart key="get_shipping_total"') . '</div>'; |
| 2533 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Tax', 'e2pdf-wc-cart key="get_shipping_tax"') . '</div>'; |
| 2534 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Taxes', 'e2pdf-wc-cart key="get_shipping_taxes"') . '</div>'; |
| 2535 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Fees', 'e2pdf-wc-cart key="get_fees"') . '</div>'; |
| 2536 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Fee Total', 'e2pdf-wc-cart key="get_fee_total"') . '</div>'; |
| 2537 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Fee Tax', 'e2pdf-wc-cart key="get_fee_tax"') . '</div>'; |
| 2538 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Fee Taxes', 'e2pdf-wc-cart key="get_fee_taxes"') . '</div>'; |
| 2539 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Displayed Subtotal', 'e2pdf-wc-cart key="get_displayed_subtotal"') . '</div>'; |
| 2540 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Tax Price Display Mode', 'e2pdf-wc-cart key="get_tax_price_display_mode"') . '</div>'; |
| 2541 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Taxes', 'e2pdf-wc-cart key="get_taxes"') . '</div>'; |
| 2542 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Taxes Total', 'e2pdf-wc-cart key="get_taxes_total"') . '</div>'; |
| 2543 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Taxes Total', 'e2pdf-wc-cart key="get_shipping_method_title"') . '</div>'; |
| 2544 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Taxes Total', 'e2pdf-wc-cart key="get_payment_method_title"') . '</div>'; |
| 2545 |
$vc .= '</div>'; |
| 2546 |
|
| 2547 |
$vc .= '<h3 class="e2pdf-plr5">Cart Common</h3>'; |
| 2548 |
$vc .= '<div class="e2pdf-grid">'; |
| 2549 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('ID', 'e2pdf-wc-cart key="id"') . '</div>'; |
| 2550 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Author', 'e2pdf-wc-cart key="post_author"') . '</div>'; |
| 2551 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Author ID', 'e2pdf-wc-cart key="post_author_id"') . '</div>'; |
| 2552 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date', 'e2pdf-wc-cart key="post_date"') . '</div>'; |
| 2553 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date (GMT)', 'e2pdf-wc-cart key="post_date_gmt"') . '</div>'; |
| 2554 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Content', 'e2pdf-wc-cart key="post_content"') . '</div>'; |
| 2555 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Title', 'e2pdf-wc-cart key="post_title"') . '</div>'; |
| 2556 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Excerpt', 'e2pdf-wc-cart key="post_excerpt"') . '</div>'; |
| 2557 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Status', 'e2pdf-wc-cart key="post_status"') . '</div>'; |
| 2558 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Comment Status', 'e2pdf-wc-cart key="comment_status"') . '</div>'; |
| 2559 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Ping Status', 'e2pdf-wc-cart key="ping_status"') . '</div>'; |
| 2560 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Password', 'e2pdf-wc-cart key="post_password"') . '</div>'; |
| 2561 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Name', 'e2pdf-wc-cart key="post_name"') . '</div>'; |
| 2562 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('To Ping', 'e2pdf-wc-cart key="to_ping"') . '</div>'; |
| 2563 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Ping', 'e2pdf-wc-cart key="pinged"') . '</div>'; |
| 2564 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Modified Date', 'e2pdf-wc-cart key="post_modified"') . '</div>'; |
| 2565 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Modified Date (GMT)', 'e2pdf-wc-cart key="post_modified_gmt"') . '</div>'; |
| 2566 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Filtered Content', 'e2pdf-wc-cart key="post_content_filtered"') . '</div>'; |
| 2567 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Parent ID', 'e2pdf-wc-cart key="post_parent"') . '</div>'; |
| 2568 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('GUID', 'e2pdf-wc-cart key="guid"') . '</div>'; |
| 2569 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Menu Order', 'e2pdf-wc-cart key="menu_order"') . '</div>'; |
| 2570 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Type', 'e2pdf-wc-cart key="post_type"') . '</div>'; |
| 2571 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Mime Type', 'e2pdf-wc-cart key="post_mime_type"') . '</div>'; |
| 2572 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Comments Count', 'e2pdf-wc-cart key="comment_count"') . '</div>'; |
| 2573 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Filter', 'e2pdf-wc-cart key="filter"') . '</div>'; |
| 2574 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Thumbnail', 'e2pdf-wc-cart key="get_the_post_thumbnail"') . '</div>'; |
| 2575 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Thumbnail URL', 'e2pdf-wc-cart key="get_the_post_thumbnail_url"') . '</div>'; |
| 2576 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Permalink', 'e2pdf-wc-cart key="permalink"') . '</div>'; |
| 2577 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Permalink', 'e2pdf-wc-cart key="get_post_permalink"') . '</div>'; |
| 2578 |
$vc .= '</div>'; |
| 2579 |
|
| 2580 |
$vc .= '<h3 class="e2pdf-plr5">Cart Special Shortcodes</h3>'; |
| 2581 |
$vc .= '<div class="e2pdf-grid">'; |
| 2582 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Products', 'e2pdf-foreach shortcode="e2pdf-wc-cart" key="get_cart"][e2pdf-wc-product key="get_name" index="[e2pdf-foreach-index]" order="true" wc_filter="true"]' . "\r\n" . '[/e2pdf-foreach') . '</div>'; |
| 2583 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Totals', 'e2pdf-foreach shortcode="e2pdf-wc-cart" key="get_formatted_cart_totals"][e2pdf-wc-cart key="get_formatted_cart_totals" path="[e2pdf-foreach-key].label"]:[e2pdf-wc-cart key="get_formatted_cart_totals" path="[e2pdf-foreach-key].value"]' . "\r\n" . '[/e2pdf-foreach') . '</div>'; |
| 2584 |
$vc .= '</div>'; |
| 2585 |
|
| 2586 |
if (function_exists('wc_get_page_id')) { |
| 2587 |
$meta_keys = $this->get_post_meta_keys(false, wc_get_page_id('cart')); |
| 2588 |
if (!empty($meta_keys)) { |
| 2589 |
$vc .= '<h3 class="e2pdf-plr5">Cart Meta Keys</h3>'; |
| 2590 |
$vc .= '<div class="e2pdf-grid">'; |
| 2591 |
$i = 0; |
| 2592 |
foreach ($meta_keys as $meta_key) { |
| 2593 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wc-cart key="' . $meta_key . '" meta="true"') . '</div>'; |
| 2594 |
$i++; |
| 2595 |
} |
| 2596 |
$vc .= '</div>'; |
| 2597 |
} |
| 2598 |
} |
| 2599 |
$vc .= $this->get_vm_product_order(); |
| 2600 |
$vc .= $this->get_vm_product(); |
| 2601 |
$vc .= '<h3 class="e2pdf-plr5">Customer</h3>'; |
| 2602 |
$vc .= '<div class="e2pdf-grid">'; |
| 2603 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Taxable Address', 'e2pdf-wc-customer key="get_taxable_address"') . '</div>'; |
| 2604 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Is Vat Exempt', 'e2pdf-wc-customer key="is_vat_exempt"') . '</div>'; |
| 2605 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Is Vat Exempt', 'e2pdf-wc-customer key="get_is_vat_exempt"') . '</div>'; |
| 2606 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Has Calculated Shipping', 'e2pdf-wc-customer key="has_calculated_shipping"') . '</div>'; |
| 2607 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Calculated Shipping', 'e2pdf-wc-customer key="get_calculated_shipping"') . '</div>'; |
| 2608 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Avatar Url', 'e2pdf-wc-customer key="get_avatar_url"') . '</div>'; |
| 2609 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Username', 'e2pdf-wc-customer key="get_username"') . '</div>'; |
| 2610 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('E-mail', 'e2pdf-wc-customer key="get_email"') . '</div>'; |
| 2611 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('First Name', 'e2pdf-wc-customer key="get_first_name"') . '</div>'; |
| 2612 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Last Name', 'e2pdf-wc-customer key="get_last_name"') . '</div>'; |
| 2613 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Display Name', 'e2pdf-wc-customer key="get_display_name"') . '</div>'; |
| 2614 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Role', 'e2pdf-wc-customer key="get_role"') . '</div>'; |
| 2615 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Created', 'e2pdf-wc-customer key="get_date_created"') . '</div>'; |
| 2616 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Modified', 'e2pdf-wc-customer key="get_date_modified"') . '</div>'; |
| 2617 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing', 'e2pdf-wc-customer key="get_billing"') . '</div>'; |
| 2618 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing First Name', 'e2pdf-wc-customer key="get_billing_first_name"') . '</div>'; |
| 2619 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Last Name', 'e2pdf-wc-customer key="get_billing_last_name"') . '</div>'; |
| 2620 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Company', 'e2pdf-wc-customer key="get_billing_company"') . '</div>'; |
| 2621 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Address', 'e2pdf-wc-customer key="get_billing_address"') . '</div>'; |
| 2622 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Address 1', 'e2pdf-wc-customer key="get_billing_address_1"') . '</div>'; |
| 2623 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Address 2', 'e2pdf-wc-customer key="get_billing_address_2"') . '</div>'; |
| 2624 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing City', 'e2pdf-wc-customer key="get_billing_city"') . '</div>'; |
| 2625 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing State', 'e2pdf-wc-customer key="get_billing_state"') . '</div>'; |
| 2626 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Postcode', 'e2pdf-wc-customer key="get_billing_postcode"') . '</div>'; |
| 2627 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing E-mail', 'e2pdf-wc-customer key="get_billing_email"') . '</div>'; |
| 2628 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Phone', 'e2pdf-wc-customer key="get_billing_phone"') . '</div>'; |
| 2629 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping', 'e2pdf-wc-customer key="get_shipping"') . '</div>'; |
| 2630 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping First Name', 'e2pdf-wc-customer key="get_shipping_first_name"') . '</div>'; |
| 2631 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Last Name', 'e2pdf-wc-customer key="get_shipping_last_name"') . '</div>'; |
| 2632 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Company', 'e2pdf-wc-customer key="get_shipping_company"') . '</div>'; |
| 2633 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Address', 'e2pdf-wc-customer key="get_shipping_address"') . '</div>'; |
| 2634 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Address 1', 'e2pdf-wc-customer key="get_shipping_address_1"') . '</div>'; |
| 2635 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Address 2', 'e2pdf-wc-customer key="get_shipping_address_2"') . '</div>'; |
| 2636 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping City', 'e2pdf-wc-customer key="get_shipping_city"') . '</div>'; |
| 2637 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping State', 'e2pdf-wc-customer key="get_shipping_state"') . '</div>'; |
| 2638 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Postcode', 'e2pdf-wc-customer key="get_shipping_postcode"') . '</div>'; |
| 2639 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Country', 'e2pdf-wc-customer key="get_shipping_country"') . '</div>'; |
| 2640 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Is Paying Customer', 'e2pdf-wc-customer key="get_is_paying_customer"') . '</div>'; |
| 2641 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Shipping Address', 'e2pdf-wc-customer key="get_formatted_shipping_address"') . '</div>'; |
| 2642 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Billing Address', 'e2pdf-wc-customer key="get_formatted_billing_address"') . '</div>'; |
| 2643 |
$vc .= '</div>'; |
| 2644 |
} |
| 2645 |
|
| 2646 |
if ($this->get('item') == 'shop_order' || $this->get('item') == 'shop_subscription') { |
| 2647 |
$vc .= $this->get_vm_order($this->get('item')); |
| 2648 |
$vc .= '<h3 class="e2pdf-plr5">Order Common</h3>'; |
| 2649 |
$vc .= '<div class="e2pdf-grid">'; |
| 2650 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('ID', 'e2pdf-wc-order key="id"') . '</div>'; |
| 2651 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Author', 'e2pdf-wc-order key="post_author"') . '</div>'; |
| 2652 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Author ID', 'e2pdf-wc-order key="post_author_id"') . '</div>'; |
| 2653 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date', 'e2pdf-wc-order key="post_date"') . '</div>'; |
| 2654 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date (GMT)', 'e2pdf-wc-order key="post_date_gmt"') . '</div>'; |
| 2655 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Content', 'e2pdf-wc-order key="post_content"') . '</div>'; |
| 2656 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Title', 'e2pdf-wc-order key="post_title"') . '</div>'; |
| 2657 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Excerpt', 'e2pdf-wc-order key="post_excerpt"') . '</div>'; |
| 2658 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Status', 'e2pdf-wc-order key="post_status"') . '</div>'; |
| 2659 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Comment Status', 'e2pdf-wc-order key="comment_status"') . '</div>'; |
| 2660 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Ping Status', 'e2pdf-wc-order key="ping_status"') . '</div>'; |
| 2661 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Password', 'e2pdf-wc-order key="post_password"') . '</div>'; |
| 2662 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Name', 'e2pdf-wc-order key="post_name"') . '</div>'; |
| 2663 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('To Ping', 'e2pdf-wc-order key="to_ping"') . '</div>'; |
| 2664 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Ping', 'e2pdf-wc-order key="pinged"') . '</div>'; |
| 2665 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Modified Date', 'e2pdf-wc-order key="post_modified"') . '</div>'; |
| 2666 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Modified Date (GMT)', 'e2pdf-wc-order key="post_modified_gmt"') . '</div>'; |
| 2667 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Filtered Content', 'e2pdf-wc-order key="post_content_filtered"') . '</div>'; |
| 2668 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Parent ID', 'e2pdf-wc-order key="post_parent"') . '</div>'; |
| 2669 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('GUID', 'e2pdf-wc-order key="guid"') . '</div>'; |
| 2670 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Menu Order', 'e2pdf-wc-order key="menu_order"') . '</div>'; |
| 2671 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Type', 'e2pdf-wc-order key="post_type"') . '</div>'; |
| 2672 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Mime Type', 'e2pdf-wc-order key="post_mime_type"') . '</div>'; |
| 2673 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Comments Count', 'e2pdf-wc-order key="comment_count"') . '</div>'; |
| 2674 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Filter', 'e2pdf-wc-order key="filter"') . '</div>'; |
| 2675 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Thumbnail', 'e2pdf-wc-order key="get_the_post_thumbnail"') . '</div>'; |
| 2676 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Thumbnail URL', 'e2pdf-wc-order key="get_the_post_thumbnail_url"') . '</div>'; |
| 2677 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Permalink', 'e2pdf-wc-order key="permalink"') . '</div>'; |
| 2678 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Permalink', 'e2pdf-wc-order key="get_post_permalink"') . '</div>'; |
| 2679 |
$vc .= '</div>'; |
| 2680 |
$vc .= $this->get_vm_product_order(); |
| 2681 |
$vc .= $this->get_vm_product_order_item_meta(); |
| 2682 |
$vc .= $this->get_vm_product(); |
| 2683 |
} |
| 2684 |
|
| 2685 |
if ($this->get('item') == 'product' || $this->get('item') == 'product_variation') { |
| 2686 |
$vc .= $this->get_vm_product(); |
| 2687 |
$vc .= $this->get_vm_product_order(); |
| 2688 |
$vc .= $this->get_vm_product_order_item_meta(); |
| 2689 |
$vc .= $this->get_vm_order(); |
| 2690 |
} |
| 2691 |
|
| 2692 |
if (class_exists('ACF') && function_exists('acf_get_field_groups')) { |
| 2693 |
$user_groups = acf_get_field_groups( |
| 2694 |
array( |
| 2695 |
'user_id' => 'new', |
| 2696 |
'user_form' => 'all', |
| 2697 |
) |
| 2698 |
); |
| 2699 |
if (!empty($user_groups)) { |
| 2700 |
$user_groups = array_column($user_groups, 'key'); |
| 2701 |
} |
| 2702 |
if ($this->get('item') == 'product' || $this->get('item') == 'product_variation') { |
| 2703 |
$groups = acf_get_field_groups(array('post_type' => 'product')); |
| 2704 |
} elseif ($this->get('item') == 'shop_order') { |
| 2705 |
$groups = acf_get_field_groups(array('post_type' => 'shop_order')); |
| 2706 |
} elseif ($this->get('item') == 'shop_subscription') { |
| 2707 |
$groups = acf_get_field_groups(array('post_type' => 'shop_subscription')); |
| 2708 |
} else { |
| 2709 |
$groups = array(); |
| 2710 |
} |
| 2711 |
if (!empty($groups)) { |
| 2712 |
$vc .= "<h3 class='e2pdf-plr5'>ACF</h3>"; |
| 2713 |
foreach ($groups as $group_key => $group) { |
| 2714 |
$post_id = ''; |
| 2715 |
if (!empty($user_groups)) { |
| 2716 |
if (in_array($group['key'], $user_groups, false)) { |
| 2717 |
if ($this->get('item') == '-3') { |
| 2718 |
$post_id = ' post_id="user_[e2pdf-dataset]"'; |
| 2719 |
} else { |
| 2720 |
$post_id = ' post_id="user_[e2pdf-userid]"'; |
| 2721 |
} |
| 2722 |
} |
| 2723 |
} |
| 2724 |
|
| 2725 |
$vc .= '<h3 class="e2pdf-plr5">' . $group['title'] . '</h3>'; |
| 2726 |
$vc .= "<div class='e2pdf-grid'>"; |
| 2727 |
foreach (acf_get_fields($group['key']) as $field_key => $field) { |
| 2728 |
$vc = $this->get_acf_field($vc, $field, $post_id); |
| 2729 |
} |
| 2730 |
$vc .= '</div>'; |
| 2731 |
} |
| 2732 |
} |
| 2733 |
} |
| 2734 |
|
| 2735 |
$vc .= $this->get_vm_user(); |
| 2736 |
|
| 2737 |
return $vc; |
| 2738 |
} |
| 2739 |
|
| 2740 |
public function get_acf_field($vc, $field, $post_id) { |
| 2741 |
if ($field['type'] == 'repeater' && !empty($field['sub_fields'])) { |
| 2742 |
$sub_fields = array(); |
| 2743 |
foreach ($field['sub_fields'] as $sub_field_key => $sub_field) { |
| 2744 |
$sub_fields[] = '[acf field="' . $sub_field['name'] . '"' . $post_id . ']'; |
| 2745 |
$sub_field['label'] = $field['label'] . ' ' . $sub_field['label']; |
| 2746 |
$sub_field['name'] = $field['name'] . '_0_' . $sub_field['name']; |
| 2747 |
$vc = $this->get_acf_field($vc, $sub_field, $post_id); |
| 2748 |
} |
| 2749 |
if (!empty($sub_fields)) { |
| 2750 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($field['label'] . ' Iteration', 'e2pdf-acf-repeater field="' . $field['name'] . '"' . $post_id . ']' . implode(' ', $sub_fields) . "\r\n" . '[/e2pdf-acf-repeater') . '</div>'; |
| 2751 |
} |
| 2752 |
} elseif ($field['type'] == 'group' && !empty($field['sub_fields'])) { |
| 2753 |
$sub_fields = array(); |
| 2754 |
foreach ($field['sub_fields'] as $sub_field_key => $sub_field) { |
| 2755 |
$sub_field['label'] = $field['label'] . ' ' . $sub_field['label']; |
| 2756 |
$sub_field['name'] = $field['name'] . '_' . $sub_field['name']; |
| 2757 |
$vc = $this->get_acf_field($vc, $sub_field, $post_id); |
| 2758 |
} |
| 2759 |
} else { |
| 2760 |
if ($field['name']) { |
| 2761 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($field['label'], 'acf field="' . $field['name'] . '"' . $post_id) . '</div>'; |
| 2762 |
} |
| 2763 |
} |
| 2764 |
return $vc; |
| 2765 |
} |
| 2766 |
|
| 2767 |
private function get_item_type_keys_subkeys($item_type = false) { |
| 2768 |
global $wpdb; |
| 2769 |
|
| 2770 |
$meta_data = $wpdb->get_results('SELECT DISTINCT `meta`.`meta_key`, `item`.`order_item_type` FROM `' . $wpdb->prefix . 'woocommerce_order_itemmeta` `meta` LEFT JOIN `' . $wpdb->prefix . 'woocommerce_order_items` `item` ON (`meta`.`order_item_id` = `item`.`order_item_id`)', ARRAY_A); |
| 2771 |
$meta_keys = array(); |
| 2772 |
if ($meta_data) { |
| 2773 |
foreach ($meta_data as $key => $meta) { |
| 2774 |
if ($item_type) { |
| 2775 |
if ($meta['order_item_type'] == $item_type) { |
| 2776 |
$meta_keys[] = $meta['meta_key']; |
| 2777 |
} |
| 2778 |
} else { |
| 2779 |
$field_key = array_search($meta['order_item_type'], array_column($meta_keys, 'meta_key'), false); |
| 2780 |
if ($field_key === false) { |
| 2781 |
$meta_keys[] = array( |
| 2782 |
'meta_key' => $meta['order_item_type'], |
| 2783 |
'sub_keys' => array( |
| 2784 |
$meta['meta_key'], |
| 2785 |
), |
| 2786 |
); |
| 2787 |
} else { |
| 2788 |
$meta_keys[$field_key]['sub_keys'][] = $meta['meta_key']; |
| 2789 |
} |
| 2790 |
} |
| 2791 |
} |
| 2792 |
} |
| 2793 |
|
| 2794 |
return $meta_keys; |
| 2795 |
} |
| 2796 |
|
| 2797 |
private function get_post_taxonomy_keys() { |
| 2798 |
global $wpdb; |
| 2799 |
|
| 2800 |
$meta_keys = array(); |
| 2801 |
if ($this->get('item')) { |
| 2802 |
$order_condition = array( |
| 2803 |
'orderby' => 'taxonomy', |
| 2804 |
'order' => 'desc', |
| 2805 |
); |
| 2806 |
$orderby = $this->helper->load('db')->prepare_orderby($order_condition); |
| 2807 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare |
| 2808 |
$meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `taxonomy` FROM `' . $wpdb->term_taxonomy . '` `t` ' . $orderby . '', '')); |
| 2809 |
} |
| 2810 |
|
| 2811 |
return $meta_keys; |
| 2812 |
} |
| 2813 |
|
| 2814 |
private function get_post_meta_keys($item = false, $post_id = false) { |
| 2815 |
global $wpdb; |
| 2816 |
|
| 2817 |
if (!$item) { |
| 2818 |
$item = $this->get('item'); |
| 2819 |
} |
| 2820 |
|
| 2821 |
$meta_keys = array(); |
| 2822 |
if ($item || $post_id) { |
| 2823 |
if (($item == 'shop_order' || $item == 'shop_subscription') && get_option('woocommerce_custom_orders_table_enabled') === 'yes' && get_option('woocommerce_custom_orders_table_data_sync_enabled') !== 'yes') { |
| 2824 |
$order_condition = array( |
| 2825 |
'orderby' => 'meta_key', |
| 2826 |
'order' => 'desc', |
| 2827 |
); |
| 2828 |
$orderby = $this->helper->load('db')->prepare_orderby($order_condition); |
| 2829 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare |
| 2830 |
$meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `meta_key` FROM `' . $wpdb->prefix . 'wc_orders_meta` `pm` ' . $orderby . '')); |
| 2831 |
if (class_exists('WC_Order_Data_Store_CPT')) { |
| 2832 |
$internal_meta_keys = (new WC_Order_Data_Store_CPT())->get_internal_meta_keys(); |
| 2833 |
if (!empty($internal_meta_keys) && is_array($internal_meta_keys)) { |
| 2834 |
$meta_keys = array_merge($meta_keys, $internal_meta_keys); |
| 2835 |
} |
| 2836 |
} |
| 2837 |
} else { |
| 2838 |
if ($post_id) { |
| 2839 |
$condition = array( |
| 2840 |
'p.ID' => array( |
| 2841 |
'condition' => '=', |
| 2842 |
'value' => $post_id, |
| 2843 |
'type' => '%d', |
| 2844 |
), |
| 2845 |
); |
| 2846 |
} else { |
| 2847 |
$condition = array( |
| 2848 |
'p.post_type' => array( |
| 2849 |
'condition' => '=', |
| 2850 |
'value' => $item, |
| 2851 |
'type' => '%s', |
| 2852 |
), |
| 2853 |
); |
| 2854 |
} |
| 2855 |
$order_condition = array( |
| 2856 |
'orderby' => 'meta_key', |
| 2857 |
'order' => 'desc', |
| 2858 |
); |
| 2859 |
$where = $this->helper->load('db')->prepare_where($condition); |
| 2860 |
$orderby = $this->helper->load('db')->prepare_orderby($order_condition); |
| 2861 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare |
| 2862 |
$meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `meta_key` FROM `' . $wpdb->postmeta . '` `pm` LEFT JOIN `' . $wpdb->posts . '` `p` ON (`p`.`ID` = `pm`.`post_ID`) ' . $where['sql'] . $orderby . '', $where['filter'])); |
| 2863 |
} |
| 2864 |
} |
| 2865 |
|
| 2866 |
return $meta_keys; |
| 2867 |
} |
| 2868 |
|
| 2869 |
private function get_product_attribute_keys() { |
| 2870 |
global $wpdb; |
| 2871 |
|
| 2872 |
$meta_keys = array(); |
| 2873 |
$attributes = wc_get_attribute_taxonomies(); |
| 2874 |
foreach ($attributes as $attribute) { |
| 2875 |
$meta_keys[] = array( |
| 2876 |
'id' => 'pa_' . $attribute->attribute_name, |
| 2877 |
'name' => $attribute->attribute_label, |
| 2878 |
); |
| 2879 |
} |
| 2880 |
|
| 2881 |
$condition = array( |
| 2882 |
'pm.meta_key' => array( |
| 2883 |
'condition' => '=', |
| 2884 |
'value' => '_product_attributes', |
| 2885 |
'type' => '%s', |
| 2886 |
), |
| 2887 |
); |
| 2888 |
|
| 2889 |
$order_condition = array( |
| 2890 |
'orderby' => 'pm.meta_key', |
| 2891 |
'order' => 'desc', |
| 2892 |
); |
| 2893 |
|
| 2894 |
$where = $this->helper->load('db')->prepare_where($condition); |
| 2895 |
$orderby = $this->helper->load('db')->prepare_orderby($order_condition); |
| 2896 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare |
| 2897 |
$custom_meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `meta_value` FROM `' . $wpdb->postmeta . '` `pm`' . $where['sql'] . $orderby . '', $where['filter'])); |
| 2898 |
foreach ($custom_meta_keys as $custom_meta_key) { |
| 2899 |
$custom_metas = $this->helper->load('convert')->unserialize($custom_meta_key); |
| 2900 |
if ($custom_metas && is_array($custom_metas)) { |
| 2901 |
foreach ($custom_metas as $custom_metas_key => $custom_metas_value) { |
| 2902 |
if (isset($custom_metas_value['is_taxonomy']) && $custom_metas_value['is_taxonomy']) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf |
| 2903 |
} else { |
| 2904 |
$in_array = array_search($custom_metas_key, array_column($meta_keys, 'id'), false); |
| 2905 |
if ($in_array === false && isset($custom_metas_value['name'])) { |
| 2906 |
$meta_keys[] = array( |
| 2907 |
'id' => $custom_metas_key, |
| 2908 |
'name' => $custom_metas_value['name'], |
| 2909 |
); |
| 2910 |
} |
| 2911 |
} |
| 2912 |
} |
| 2913 |
} |
| 2914 |
} |
| 2915 |
|
| 2916 |
return $meta_keys; |
| 2917 |
} |
| 2918 |
|
| 2919 |
private function get_vm_element($name, $id) { |
| 2920 |
$element = '<div>'; |
| 2921 |
$element .= '<label>' . $name . ':</label>'; |
| 2922 |
$element .= '<input type="text" name=\'[' . $id . ']\' value=\'[' . $id . ']\' class="e2pdf-w100">'; |
| 2923 |
$element .= '</div>'; |
| 2924 |
return $element; |
| 2925 |
} |
| 2926 |
|
| 2927 |
private function get_vm_product() { |
| 2928 |
|
| 2929 |
$index = ''; |
| 2930 |
if ($this->get('item') == 'shop_order' || $this->get('item') == 'shop_subscription' || $this->get('item') == 'cart') { |
| 2931 |
$index = ' index="0"'; |
| 2932 |
} |
| 2933 |
|
| 2934 |
$vc = ''; |
| 2935 |
|
| 2936 |
$vc .= '<h3 class="e2pdf-plr5">Product</h3>'; |
| 2937 |
$vc .= '<div class="e2pdf-grid">'; |
| 2938 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Name', 'e2pdf-wc-product key="get_name"' . $index) . '</div>'; |
| 2939 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Type', 'e2pdf-wc-product key="get_type"' . $index) . '</div>'; |
| 2940 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Slug', 'e2pdf-wc-product key="get_slug"' . $index) . '</div>'; |
| 2941 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Created', 'e2pdf-wc-product key="get_date_created"' . $index) . '</div>'; |
| 2942 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Modified', 'e2pdf-wc-product key="get_date_modified"' . $index) . '</div>'; |
| 2943 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Status', 'e2pdf-wc-product key="get_status"' . $index) . '</div>'; |
| 2944 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Featured', 'e2pdf-wc-product key="get_featured"' . $index) . '</div>'; |
| 2945 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Catalog Visibility', 'e2pdf-wc-product key="get_catalog_visibility"' . $index) . '</div>'; |
| 2946 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Description', 'e2pdf-wc-product key="get_description" wc_format_content="true"' . $index) . '</div>'; |
| 2947 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Short Description', 'e2pdf-wc-product key="get_short_description" wc_format_content="true"' . $index) . '</div>'; |
| 2948 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Sku', 'e2pdf-wc-product key="get_sku"' . $index) . '</div>'; |
| 2949 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Price', 'e2pdf-wc-product key="get_price"' . $index) . '</div>'; |
| 2950 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Regular Price', 'e2pdf-wc-product key="get_regular_price"' . $index) . '</div>'; |
| 2951 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Sale Price', 'e2pdf-wc-product key="get_sale_price"' . $index) . '</div>'; |
| 2952 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Sale From', 'e2pdf-wc-product key="get_date_on_sale_from"' . $index) . '</div>'; |
| 2953 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Sale To', 'e2pdf-wc-product key="get_date_on_sale_to"' . $index) . '</div>'; |
| 2954 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Sales', 'e2pdf-wc-product key="get_total_sales"' . $index) . '</div>'; |
| 2955 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Tax Status', 'e2pdf-wc-product key="get_tax_status"' . $index) . '</div>'; |
| 2956 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Tax Class', 'e2pdf-wc-product key="get_tax_class"' . $index) . '</div>'; |
| 2957 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Manage Stock', 'e2pdf-wc-product key="get_manage_stock"' . $index) . '</div>'; |
| 2958 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Stock Quantity', 'e2pdf-wc-product key="get_stock_quantity"' . $index) . '</div>'; |
| 2959 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Stock Status', 'e2pdf-wc-product key="get_stock_status"' . $index) . '</div>'; |
| 2960 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Backorders', 'e2pdf-wc-product key="get_backorders"' . $index) . '</div>'; |
| 2961 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Low Stock Amount', 'e2pdf-wc-product key="get_low_stock_amount"' . $index) . '</div>'; |
| 2962 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Sold Individually', 'e2pdf-wc-product key="get_sold_individually"' . $index) . '</div>'; |
| 2963 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Weight', 'e2pdf-wc-product key="get_weight"' . $index) . '</div>'; |
| 2964 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Length', 'e2pdf-wc-product key="get_length"' . $index) . '</div>'; |
| 2965 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Width', 'e2pdf-wc-product key="get_width"' . $index) . '</div>'; |
| 2966 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Height', 'e2pdf-wc-product key="get_height"' . $index) . '</div>'; |
| 2967 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Dimensions', 'e2pdf-wc-product key="get_dimensions"' . $index) . '</div>'; |
| 2968 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Upsell IDs', 'e2pdf-wc-product key="get_upsell_ids"' . $index) . '</div>'; |
| 2969 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cross Sell IDs', 'e2pdf-wc-product key="get_cross_sell_ids"' . $index) . '</div>'; |
| 2970 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Parent ID', 'e2pdf-wc-product key="get_parent_id"' . $index) . '</div>'; |
| 2971 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Reviews Allowed', 'e2pdf-wc-product key="get_reviews_allowed"' . $index) . '</div>'; |
| 2972 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Purchase Note', 'e2pdf-wc-product key="get_purchase_note"' . $index) . '</div>'; |
| 2973 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Attributes', 'e2pdf-wc-product key="get_attributes"' . $index) . '</div>'; |
| 2974 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Default Attributes', 'e2pdf-wc-product key="get_default_attributes"' . $index) . '</div>'; |
| 2975 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Menu Order', 'e2pdf-wc-product key="get_menu_order"' . $index) . '</div>'; |
| 2976 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Password', 'e2pdf-wc-product key="get_post_password"' . $index) . '</div>'; |
| 2977 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Category IDs', 'e2pdf-wc-product key="get_category_ids"' . $index) . '</div>'; |
| 2978 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Tag IDs', 'e2pdf-wc-product key="get_tag_ids"' . $index) . '</div>'; |
| 2979 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Virtual', 'e2pdf-wc-product key="get_virtual"' . $index) . '</div>'; |
| 2980 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Gallery Image IDs', 'e2pdf-wc-product key="get_gallery_image_ids"' . $index) . '</div>'; |
| 2981 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Class ID', 'e2pdf-wc-product key="get_shipping_class_id"' . $index) . '</div>'; |
| 2982 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Downloads', 'e2pdf-wc-product key="get_downloads"' . $index) . '</div>'; |
| 2983 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Download Expiry', 'e2pdf-wc-product key="get_download_expiry"' . $index) . '</div>'; |
| 2984 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Downloadable', 'e2pdf-wc-product key="get_downloadable"' . $index) . '</div>'; |
| 2985 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Download Limit', 'e2pdf-wc-product key="get_download_limit"' . $index) . '</div>'; |
| 2986 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Image ID', 'e2pdf-wc-product key="get_image_id"' . $index) . '</div>'; |
| 2987 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Rating Counts', 'e2pdf-wc-product key="get_rating_counts"' . $index) . '</div>'; |
| 2988 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Average Rating', 'e2pdf-wc-product key="get_average_rating"' . $index) . '</div>'; |
| 2989 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Review Count', 'e2pdf-wc-product key="get_review_count"' . $index) . '</div>'; |
| 2990 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Title', 'e2pdf-wc-product key="get_title"' . $index) . '</div>'; |
| 2991 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Product Permalink', 'e2pdf-wc-product key="get_permalink"' . $index) . '</div>'; |
| 2992 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Children', 'e2pdf-wc-product key="get_children"' . $index) . '</div>'; |
| 2993 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Stock Managed ID', 'e2pdf-wc-product key="get_stock_managed_by_id"' . $index) . '</div>'; |
| 2994 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Price (HTML)', 'e2pdf-wc-product key="get_price_html"' . $index) . '</div>'; |
| 2995 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Name', 'e2pdf-wc-product key="get_formatted_name"' . $index) . '</div>'; |
| 2996 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Min Purchase Quantity', 'e2pdf-wc-product key="get_min_purchase_quantity"' . $index) . '</div>'; |
| 2997 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Max Purchase Quantity', 'e2pdf-wc-product key="get_max_purchase_quantity"' . $index) . '</div>'; |
| 2998 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Image', 'e2pdf-wc-product key="get_image"' . $index) . '</div>'; |
| 2999 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Class', 'e2pdf-wc-product key="get_shipping_class"' . $index) . '</div>'; |
| 3000 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Rating Count', 'e2pdf-wc-product key="get_rating_count"' . $index) . '</div>'; |
| 3001 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('File', 'e2pdf-wc-product key="get_file"' . $index) . '</div>'; |
| 3002 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('File Download Path', 'e2pdf-wc-product key="get_file_download_path"' . $index) . '</div>'; |
| 3003 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Price Suffix', 'e2pdf-wc-product key="get_price_suffix"' . $index) . '</div>'; |
| 3004 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Availability', 'e2pdf-wc-product key="get_availability"' . $index) . '</div>'; |
| 3005 |
if ($this->get('item') == 'product_variation') { |
| 3006 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Product Variation Attributes', 'e2pdf-wc-product key="get_variation_attributes"' . $index) . '</div>'; |
| 3007 |
} |
| 3008 |
$vc .= '</div>'; |
| 3009 |
|
| 3010 |
$vc .= '<h3 class="e2pdf-plr5">Product Common</h3>'; |
| 3011 |
$vc .= '<div class="e2pdf-grid">'; |
| 3012 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('ID', 'e2pdf-wc-product key="id"' . $index) . '</div>'; |
| 3013 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Author', 'e2pdf-wc-product key="post_author"' . $index) . '</div>'; |
| 3014 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Author ID', 'e2pdf-wc-product key="post_author_id"' . $index) . '</div>'; |
| 3015 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date', 'e2pdf-wc-product key="post_date"' . $index) . '</div>'; |
| 3016 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date (GMT)', 'e2pdf-wc-product key="post_date_gmt"' . $index) . '</div>'; |
| 3017 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Content', 'e2pdf-wc-product key="post_content"' . $index) . '</div>'; |
| 3018 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Title', 'e2pdf-wc-product key="post_title"' . $index) . '</div>'; |
| 3019 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Excerpt', 'e2pdf-wc-product key="post_excerpt"' . $index) . '</div>'; |
| 3020 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Status', 'e2pdf-wc-product key="post_status"' . $index) . '</div>'; |
| 3021 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Comment Status', 'e2pdf-wc-product key="comment_status"' . $index) . '</div>'; |
| 3022 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Ping Status', 'e2pdf-wc-product key="ping_status"' . $index) . '</div>'; |
| 3023 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Password', 'e2pdf-wc-product key="post_password"' . $index) . '</div>'; |
| 3024 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Name', 'e2pdf-wc-product key="post_name"' . $index) . '</div>'; |
| 3025 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('To Ping', 'e2pdf-wc-product key="to_ping"' . $index) . '</div>'; |
| 3026 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Ping', 'e2pdf-wc-product key="pinged"' . $index) . '</div>'; |
| 3027 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Modified Date', 'e2pdf-wc-product key="post_modified"' . $index) . '</div>'; |
| 3028 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Modified Date (GMT)', 'e2pdf-wc-product key="post_modified_gmt"' . $index) . '</div>'; |
| 3029 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Filtered Content', 'e2pdf-wc-product key="post_content_filtered"' . $index) . '</div>'; |
| 3030 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Parent ID', 'e2pdf-wc-product key="post_parent"' . $index) . '</div>'; |
| 3031 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('GUID', 'e2pdf-wc-product key="guid"' . $index) . '</div>'; |
| 3032 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Menu Order', 'e2pdf-wc-product key="menu_order"' . $index) . '</div>'; |
| 3033 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Type', 'e2pdf-wc-product key="post_type"' . $index) . '</div>'; |
| 3034 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Mime Type', 'e2pdf-wc-product key="post_mime_type"' . $index) . '</div>'; |
| 3035 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Comments Count', 'e2pdf-wc-product key="comment_count"' . $index) . '</div>'; |
| 3036 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Filter', 'e2pdf-wc-product key="filter"' . $index) . '</div>'; |
| 3037 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Thumbnail', 'e2pdf-wc-product key="get_the_post_thumbnail"' . $index) . '</div>'; |
| 3038 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Thumbnail URL', 'e2pdf-wc-product key="get_the_post_thumbnail_url"' . $index) . '</div>'; |
| 3039 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Permalink', 'e2pdf-wc-product key="permalink"' . $index) . '</div>'; |
| 3040 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Permalink', 'e2pdf-wc-product key="get_post_permalink"' . $index) . '</div>'; |
| 3041 |
$vc .= '</div>'; |
| 3042 |
|
| 3043 |
$meta_keys = $this->get_product_attribute_keys(); |
| 3044 |
$vc .= '<h3 class="e2pdf-plr5">Product Attributes</h3>'; |
| 3045 |
$vc .= '<div class="e2pdf-grid">'; |
| 3046 |
$i = 0; |
| 3047 |
foreach ($meta_keys as $meta_key) { |
| 3048 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key['name'], 'e2pdf-wc-product key="get_attribute" attribute="' . $meta_key['id'] . '" show="value"' . $index) . '</div>'; |
| 3049 |
|
| 3050 |
$i++; |
| 3051 |
} |
| 3052 |
$vc .= '</div>'; |
| 3053 |
|
| 3054 |
$vc .= '<h3 class="e2pdf-plr5">Product Special Shortcodes</h3>'; |
| 3055 |
$vc .= '<div class="e2pdf-grid">'; |
| 3056 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Product Attributes', 'e2pdf-foreach shortcode="e2pdf-wc-product" key="get_attributes"' . $index . ' wc_filter="true"][e2pdf-wc-product key="get_attributes" path="[e2pdf-foreach-key].label" wc_filter="true"' . $index . ']: [e2pdf-wc-product key="get_attributes" path="[e2pdf-foreach-key].value" wc_filter="true"' . $index . ']' . "\r\n" . '[/e2pdf-foreach') . '</div>'; |
| 3057 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Meta Data', 'e2pdf-foreach shortcode="e2pdf-wc-product" key="get_formatted_meta_data"' . $index . '][e2pdf-wc-product key="get_formatted_meta_data" path="[e2pdf-foreach-key].display_key"' . $index . ']:[e2pdf-wc-product key="get_formatted_meta_data" path="[e2pdf-foreach-key].display_value"' . $index . ']' . "\r\n" . '[/e2pdf-foreach') . '</div>'; |
| 3058 |
if ($this->get('item') == 'product_variation') { |
| 3059 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Product Variation Attributes', 'e2pdf-foreach shortcode="e2pdf-wc-product" key="get_variation_attributes"' . $index . ' wc_filter="true"][e2pdf-wc-product key="get_variation_attributes" path="[e2pdf-foreach-key].label" wc_filter="true"' . $index . ']: [e2pdf-wc-product key="get_variation_attributes" path="[e2pdf-foreach-key].value" wc_filter="true"' . $index . ']' . "\r\n" . '[/e2pdf-foreach') . '</div>'; |
| 3060 |
} |
| 3061 |
|
| 3062 |
$vc .= '</div>'; |
| 3063 |
|
| 3064 |
$meta_keys = $this->get_post_meta_keys('product'); |
| 3065 |
$meta_keys2 = $this->get_post_meta_keys('product_variation'); |
| 3066 |
|
| 3067 |
if (!empty($meta_keys2)) { |
| 3068 |
foreach ($meta_keys2 as $meta_key) { |
| 3069 |
if (!in_array($meta_key, $meta_keys, false)) { |
| 3070 |
$meta_keys[] = $meta_key; |
| 3071 |
} |
| 3072 |
} |
| 3073 |
} |
| 3074 |
|
| 3075 |
if (!empty($meta_keys)) { |
| 3076 |
$vc .= '<h3 class="e2pdf-plr5">Product Meta Keys</h3>'; |
| 3077 |
$vc .= '<div class="e2pdf-grid">'; |
| 3078 |
$i = 0; |
| 3079 |
foreach ($meta_keys as $meta_key) { |
| 3080 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wc-product key="' . $meta_key . '" meta="true"' . $index) . '</div>'; |
| 3081 |
$i++; |
| 3082 |
} |
| 3083 |
$vc .= '</div>'; |
| 3084 |
} |
| 3085 |
|
| 3086 |
$meta_keys = $this->get_post_taxonomy_keys(); |
| 3087 |
if (!empty($meta_keys)) { |
| 3088 |
$vc .= '<h3 class="e2pdf-plr5">Product Taxonomy</h3>'; |
| 3089 |
$vc .= '<div class="e2pdf-grid">'; |
| 3090 |
$i = 0; |
| 3091 |
foreach ($meta_keys as $meta_key) { |
| 3092 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wc-product key="' . $meta_key . '" terms="true" names="true"' . $index) . '</div>'; |
| 3093 |
$i++; |
| 3094 |
} |
| 3095 |
$vc .= '</div>'; |
| 3096 |
} |
| 3097 |
|
| 3098 |
return $vc; |
| 3099 |
} |
| 3100 |
|
| 3101 |
private function get_vm_product_order() { |
| 3102 |
$index = ''; |
| 3103 |
if ($this->get('item') == 'shop_order' || $this->get('item') == 'shop_subscription' || $this->get('item') == 'cart') { |
| 3104 |
$index = ' index="0"'; |
| 3105 |
} |
| 3106 |
|
| 3107 |
$vc = ''; |
| 3108 |
|
| 3109 |
if ($this->get('item') == 'cart') { |
| 3110 |
$vc .= '<h3 class="e2pdf-plr5">Cart Product</h3>'; |
| 3111 |
} else { |
| 3112 |
$vc .= '<h3 class="e2pdf-plr5">Order Product</h3>'; |
| 3113 |
} |
| 3114 |
$vc .= '<div class="e2pdf-grid">'; |
| 3115 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Name', 'e2pdf-wc-product key="get_name" order="true"' . $index) . '</div>'; |
| 3116 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Type', 'e2pdf-wc-product key="get_type" order="true"' . $index) . '</div>'; |
| 3117 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Quantity', 'e2pdf-wc-product key="get_quantity" order="true"' . $index) . '</div>'; |
| 3118 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Tax Status', 'e2pdf-wc-product key="get_tax_status" order="true"' . $index) . '</div>'; |
| 3119 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Tax Class', 'e2pdf-wc-product key="get_tax_class" order="true"' . $index) . '</div>'; |
| 3120 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Meta Data', 'e2pdf-wc-product key="get_formatted_meta_data" order="true"' . $index) . '</div>'; |
| 3121 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Product ID', 'e2pdf-wc-product key="get_product_id" order="true"' . $index) . '</div>'; |
| 3122 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Variation ID', 'e2pdf-wc-product key="get_variation_id" order="true"' . $index) . '</div>'; |
| 3123 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Subtotal', 'e2pdf-wc-product key="get_subtotal" order="true"' . $index) . '</div>'; |
| 3124 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Subtotal Tax', 'e2pdf-wc-product key="get_subtotal_tax" order="true"' . $index) . '</div>'; |
| 3125 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total', 'e2pdf-wc-product key="get_total" order="true"' . $index) . '</div>'; |
| 3126 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Tax', 'e2pdf-wc-product key="get_total_tax" order="true"' . $index) . '</div>'; |
| 3127 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Taxes', 'e2pdf-wc-product key="get_taxes" order="true"' . $index) . '</div>'; |
| 3128 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Item Download URL', 'e2pdf-wc-product key="get_item_download_url" order="true" index="0" download_order="true"' . $index) . '</div>'; |
| 3129 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Downloads', 'e2pdf-wc-product key="get_item_downloads" order="true"' . $index) . '</div>'; |
| 3130 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Item Subtotal', 'e2pdf-wc-product key="get_item_subtotal" order="true"' . $index) . '</div>'; |
| 3131 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Item Total', 'e2pdf-wc-product key="get_item_total" order="true"' . $index) . '</div>'; |
| 3132 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Item Tax', 'e2pdf-wc-product key="get_item_tax" order="true"' . $index) . '</div>'; |
| 3133 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Line Total', 'e2pdf-wc-product key="get_line_total" order="true"' . $index) . '</div>'; |
| 3134 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Line Tax', 'e2pdf-wc-product key="get_line_tax" order="true"' . $index) . '</div>'; |
| 3135 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Line Subtotal', 'e2pdf-wc-product key="get_formatted_line_subtotal" order="true"' . $index) . '</div>'; |
| 3136 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Order Item ID', 'e2pdf-wc-product key="get_order_item_id" order="true"' . $index) . '</div>'; |
| 3137 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Order Response Hook', 'e2pdf-wc-product key="order_response_hook" order="true"' . $index) . '</div>'; |
| 3138 |
|
| 3139 |
if ($this->get('item') == 'cart') { |
| 3140 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Item Cart Response Hook', 'e2pdf-wc-product key="item_cart_response_hook"' . $index) . '</div>'; |
| 3141 |
} else { |
| 3142 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Item Response Hook', 'e2pdf-wc-product key="item_response_hook" order="true"' . $index) . '</div>'; |
| 3143 |
} |
| 3144 |
|
| 3145 |
$vc .= '</div>'; |
| 3146 |
|
| 3147 |
return $vc; |
| 3148 |
} |
| 3149 |
|
| 3150 |
private function get_vm_product_order_item_meta() { |
| 3151 |
|
| 3152 |
$index = ''; |
| 3153 |
if ($this->get('item') == 'shop_order' || $this->get('item') == 'shop_subscription' || $this->get('item') == 'cart') { |
| 3154 |
$index = ' index="0"'; |
| 3155 |
} |
| 3156 |
|
| 3157 |
$vc = ''; |
| 3158 |
$meta_keys = $this->get_item_type_keys_subkeys('line_item'); |
| 3159 |
if (!empty($meta_keys)) { |
| 3160 |
$vc .= '<h3 class="e2pdf-plr5">Order Product Item Meta Keys</h3>'; |
| 3161 |
$vc .= '<div class="e2pdf-grid">'; |
| 3162 |
$i = 0; |
| 3163 |
foreach ($meta_keys as $meta_key) { |
| 3164 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wc-product key="' . $meta_key . '" order_item_meta="true"' . $index) . '</div>'; |
| 3165 |
$i++; |
| 3166 |
} |
| 3167 |
$vc .= '</div>'; |
| 3168 |
} |
| 3169 |
|
| 3170 |
return $vc; |
| 3171 |
} |
| 3172 |
|
| 3173 |
private function get_vm_order($post_type = 'shop_order') { |
| 3174 |
|
| 3175 |
$vc = ''; |
| 3176 |
$vc .= '<h3 class="e2pdf-plr5">Order</h3>'; |
| 3177 |
$vc .= '<div class="e2pdf-grid">'; |
| 3178 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Order ID', 'e2pdf-wc-order key="get_id"') . '</div>'; |
| 3179 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Order Key', 'e2pdf-wc-order key="get_order_key"') . '</div>'; |
| 3180 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Order Number', 'e2pdf-wc-order key="get_order_number"') . '</div>'; |
| 3181 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Order Total', 'e2pdf-wc-order key="get_formatted_order_total"') . '</div>'; |
| 3182 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart Tax', 'e2pdf-wc-order key="get_cart_tax"') . '</div>'; |
| 3183 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Currency', 'e2pdf-wc-order key="get_currency"') . '</div>'; |
| 3184 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Discount Tax', 'e2pdf-wc-order key="get_discount_tax"') . '</div>'; |
| 3185 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Discount to Display', 'e2pdf-wc-order key="get_discount_to_display"') . '</div>'; |
| 3186 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Discount Total', 'e2pdf-wc-order key="get_discount_total"') . '</div>'; |
| 3187 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Tax', 'e2pdf-wc-order key="get_shipping_tax"') . '</div>'; |
| 3188 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Total', 'e2pdf-wc-order key="get_shipping_total"') . '</div>'; |
| 3189 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Subtotal', 'e2pdf-wc-order key="get_subtotal"') . '</div>'; |
| 3190 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Subtotal to Display', 'e2pdf-wc-order key="get_subtotal_to_display"') . '</div>'; |
| 3191 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Get Total', 'e2pdf-wc-order key="get_total"') . '</div>'; |
| 3192 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Discount', 'e2pdf-wc-order key="get_total_discount"') . '</div>'; |
| 3193 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Tax', 'e2pdf-wc-order key="get_total_tax"') . '</div>'; |
| 3194 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Refunded', 'e2pdf-wc-order key="get_total_refunded"') . '</div>'; |
| 3195 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Tax Refunded', 'e2pdf-wc-order key="get_total_tax_refunded"') . '</div>'; |
| 3196 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total Shipping Refunded', 'e2pdf-wc-order key="get_total_shipping_refunded"') . '</div>'; |
| 3197 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Item Count Refunded', 'e2pdf-wc-order key="get_item_count_refunded"') . '</div>'; |
| 3198 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Total QTY Refunded', 'e2pdf-wc-order key="get_total_qty_refunded"') . '</div>'; |
| 3199 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Remaining Refund Amount', 'e2pdf-wc-order key="get_remaining_refund_amount"') . '</div>'; |
| 3200 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Item Count', 'e2pdf-wc-order key="get_item_count"') . '</div>'; |
| 3201 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Method', 'e2pdf-wc-order key="get_shipping_method"') . '</div>'; |
| 3202 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping to Display', 'e2pdf-wc-order key="get_shipping_to_display"') . '</div>'; |
| 3203 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Created', 'e2pdf-wc-order key="get_date_created"') . '</div>'; |
| 3204 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Modified', 'e2pdf-wc-order key="get_date_modified"') . '</div>'; |
| 3205 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Completed', 'e2pdf-wc-order key="get_date_completed"') . '</div>'; |
| 3206 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date Paid', 'e2pdf-wc-order key="get_date_paid"') . '</div>'; |
| 3207 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Custom ID', 'e2pdf-wc-order key="get_customer_id"') . '</div>'; |
| 3208 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('User ID', 'e2pdf-wc-order key="get_user_id"') . '</div>'; |
| 3209 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Customer IP Address', 'e2pdf-wc-order key="get_customer_ip_address"') . '</div>'; |
| 3210 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Customer User Agent', 'e2pdf-wc-order key="get_customer_user_agent"') . '</div>'; |
| 3211 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Created Via', 'e2pdf-wc-order key="get_created_via"') . '</div>'; |
| 3212 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Customer Note', 'e2pdf-wc-order key="get_customer_note"') . '</div>'; |
| 3213 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing First Name', 'e2pdf-wc-order key="get_billing_first_name"') . '</div>'; |
| 3214 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Last Name', 'e2pdf-wc-order key="get_billing_last_name"') . '</div>'; |
| 3215 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Company', 'e2pdf-wc-order key="get_billing_company"') . '</div>'; |
| 3216 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Address 1', 'e2pdf-wc-order key="get_billing_address_1"') . '</div>'; |
| 3217 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Address 2', 'e2pdf-wc-order key="get_billing_address_2"') . '</div>'; |
| 3218 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing City', 'e2pdf-wc-order key="get_billing_city"') . '</div>'; |
| 3219 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing State', 'e2pdf-wc-order key="get_billing_state"') . '</div>'; |
| 3220 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Postcode', 'e2pdf-wc-order key="get_billing_postcode"') . '</div>'; |
| 3221 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Country', 'e2pdf-wc-order key="get_billing_country"') . '</div>'; |
| 3222 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing E-mail', 'e2pdf-wc-order key="get_billing_email"') . '</div>'; |
| 3223 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Billing Phone', 'e2pdf-wc-order key="get_billing_phone"') . '</div>'; |
| 3224 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shopping First Name', 'e2pdf-wc-order key="get_shipping_first_name"') . '</div>'; |
| 3225 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Last Name', 'e2pdf-wc-order key="get_shipping_last_name"') . '</div>'; |
| 3226 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Company', 'e2pdf-wc-order key="get_shipping_company"') . '</div>'; |
| 3227 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Address 1', 'e2pdf-wc-order key="get_shipping_address_1"') . '</div>'; |
| 3228 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Address 2', 'e2pdf-wc-order key="get_shipping_address_2"') . '</div>'; |
| 3229 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping City', 'e2pdf-wc-order key="get_shipping_city"') . '</div>'; |
| 3230 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping State', 'e2pdf-wc-order key="get_shipping_state"') . '</div>'; |
| 3231 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Postcode', 'e2pdf-wc-order key="get_shipping_postcode"') . '</div>'; |
| 3232 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Country', 'e2pdf-wc-order key="get_shipping_country"') . '</div>'; |
| 3233 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Shipping Address Map URL', 'e2pdf-wc-order key="get_shipping_address_map_url"') . '</div>'; |
| 3234 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Billing Full Name', 'e2pdf-wc-order key="get_formatted_billing_full_name"') . '</div>'; |
| 3235 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Shipping Full Name', 'e2pdf-wc-order key="get_formatted_shipping_full_name"') . '</div>'; |
| 3236 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Billing Address', 'e2pdf-wc-order key="get_formatted_billing_address"') . '</div>'; |
| 3237 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Formatted Shipping Address', 'e2pdf-wc-order key="get_formatted_shipping_address"') . '</div>'; |
| 3238 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Payment Method', 'e2pdf-wc-order key="get_payment_method"') . '</div>'; |
| 3239 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Payment Method Title', 'e2pdf-wc-order key="get_payment_method_title"') . '</div>'; |
| 3240 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Transaction ID', 'e2pdf-wc-order key="get_transaction_id"') . '</div>'; |
| 3241 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Checkout Payment URL', 'e2pdf-wc-order key="get_checkout_payment_url"') . '</div>'; |
| 3242 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Checkout Order Received URL', 'e2pdf-wc-order key="get_checkout_order_received_url"') . '</div>'; |
| 3243 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cancel Order URL', 'e2pdf-wc-order key="get_cancel_order_url"') . '</div>'; |
| 3244 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cancel Order URL (raw)', 'e2pdf-wc-order key="get_cancel_order_url_raw"') . '</div>'; |
| 3245 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cancel Endpoint', 'e2pdf-wc-order key="get_cancel_endpoint"') . '</div>'; |
| 3246 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('View Order URL', 'e2pdf-wc-order key="get_view_order_url"') . '</div>'; |
| 3247 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Edit Order URL', 'e2pdf-wc-order key="get_edit_order_url"') . '</div>'; |
| 3248 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Status', 'e2pdf-wc-order key="get_status"') . '</div>'; |
| 3249 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Items IDs', 'e2pdf-wc-order key="get_items_ids"') . '</div>'; |
| 3250 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Items Category', 'e2pdf-wc-order key="get_items_category"') . '</div>'; |
| 3251 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Items Category IDs', 'e2pdf-wc-order key="get_items_category_ids"') . '</div>'; |
| 3252 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Cart', 'e2pdf-wc-order key="cart"') . '</div>'; |
| 3253 |
$vc .= '</div>'; |
| 3254 |
|
| 3255 |
$vc .= '<h3 class="e2pdf-plr5">Order Special Shortcodes</h3>'; |
| 3256 |
$vc .= '<div class="e2pdf-grid">'; |
| 3257 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Order Products', 'e2pdf-foreach shortcode="e2pdf-wc-order" key="get_items"][e2pdf-wc-product key="get_name" order="true" index="[e2pdf-foreach-index]"]' . "\r\n" . '[/e2pdf-foreach') . '</div>'; |
| 3258 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Order Totals', 'e2pdf-foreach shortcode="e2pdf-wc-order" key="get_order_item_totals"][e2pdf-wc-order key="get_order_item_totals" path="[e2pdf-foreach-key].label"][e2pdf-wc-order key="get_order_item_totals" path="[e2pdf-foreach-key].value"]' . "\r\n" . '[/e2pdf-foreach') . '</div>'; |
| 3259 |
|
| 3260 |
$vc .= '</div>'; |
| 3261 |
|
| 3262 |
$meta_keys = $this->get_post_meta_keys($post_type); |
| 3263 |
if (!empty($meta_keys)) { |
| 3264 |
$vc .= '<h3 class="e2pdf-plr5">Order Meta Keys</h3>'; |
| 3265 |
$vc .= '<div class="e2pdf-grid">'; |
| 3266 |
$i = 0; |
| 3267 |
foreach ($meta_keys as $meta_key) { |
| 3268 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wc-order key="' . $meta_key . '" meta="true"') . '</div>'; |
| 3269 |
$i++; |
| 3270 |
} |
| 3271 |
$vc .= '</div>'; |
| 3272 |
} |
| 3273 |
|
| 3274 |
/* |
| 3275 |
* Checkout Field Editor (Checkout Manager) for WooCommerce |
| 3276 |
* https://wordpress.org/plugins/woo-checkout-field-editor-pro/ |
| 3277 |
*/ |
| 3278 |
$meta_keys = []; |
| 3279 |
if (class_exists('WCFE_Checkout_Fields_Utils') && class_exists('THWCFE_Utils_Section')) { |
| 3280 |
$checkout_field_editor_sections = WCFE_Checkout_Fields_Utils::get_checkout_sections(); |
| 3281 |
foreach ($checkout_field_editor_sections as $checkout_field_editor_section) { |
| 3282 |
$checkout_field_editor_fields = THWCFE_Utils_Section::get_fields($checkout_field_editor_section); |
| 3283 |
$meta_keys = array_merge($meta_keys, $checkout_field_editor_fields); |
| 3284 |
} |
| 3285 |
} |
| 3286 |
if (class_exists('THWCFD_Utils')) { |
| 3287 |
$meta_keys = array_merge( |
| 3288 |
$meta_keys, |
| 3289 |
THWCFD_Utils::get_fields('billing'), |
| 3290 |
THWCFD_Utils::get_fields('shipping'), |
| 3291 |
THWCFD_Utils::get_fields('additional') |
| 3292 |
); |
| 3293 |
} |
| 3294 |
if (class_exists('THWCFD_Utils_Block') && class_exists('THWCFE_Utils_Section')) { |
| 3295 |
$checkout_field_editor_sections = THWCFD_Utils_Block::get_block_checkout_sections(); |
| 3296 |
foreach ($checkout_field_editor_sections as $checkout_field_editor_section) { |
| 3297 |
$checkout_field_editor_fields = THWCFE_Utils_Section::get_fields($checkout_field_editor_section); |
| 3298 |
$meta_keys = array_merge($meta_keys, $checkout_field_editor_fields); |
| 3299 |
} |
| 3300 |
} |
| 3301 |
if (class_exists('THWCFD_Utils_Block') && class_exists('THWCFD_Utils_Section')) { |
| 3302 |
$checkout_field_editor_sections = THWCFD_Utils_Block::get_block_checkout_sections(); |
| 3303 |
foreach ($checkout_field_editor_sections as $checkout_field_editor_section) { |
| 3304 |
$checkout_field_editor_fields = THWCFD_Utils_Section::get_fieldset($checkout_field_editor_section); |
| 3305 |
$meta_keys = array_merge($meta_keys, $checkout_field_editor_fields); |
| 3306 |
} |
| 3307 |
} |
| 3308 |
if (!empty($meta_keys)) { |
| 3309 |
$vc .= '<h3 class="e2pdf-plr5">Checkout Field Editor for WooCommerce</h3>'; |
| 3310 |
$vc .= '<div class="e2pdf-grid">'; |
| 3311 |
$i = 0; |
| 3312 |
foreach ($meta_keys as $meta_key => $meta_value) { |
| 3313 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wc-order key="' . $meta_key . '" meta="true" checkout_field_editor="true"') . '</div>'; |
| 3314 |
$i++; |
| 3315 |
} |
| 3316 |
$vc .= '</div>'; |
| 3317 |
} |
| 3318 |
|
| 3319 |
$meta_keys = $this->get_post_taxonomy_keys(); |
| 3320 |
if (!empty($meta_keys)) { |
| 3321 |
$vc .= '<h3 class="e2pdf-plr5">Order Taxonomy</h3>'; |
| 3322 |
$vc .= '<div class="e2pdf-grid">'; |
| 3323 |
$i = 0; |
| 3324 |
foreach ($meta_keys as $meta_key) { |
| 3325 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wc-order key="' . $meta_key . '" terms="true" names="true"') . '</div>'; |
| 3326 |
$i++; |
| 3327 |
} |
| 3328 |
$vc .= '</div>'; |
| 3329 |
} |
| 3330 |
|
| 3331 |
$meta_keys = $this->get_item_type_keys_subkeys(); |
| 3332 |
if (!empty($meta_keys)) { |
| 3333 |
$vc .= '<h3 class="e2pdf-plr5">Order Item Meta Keys</h3>'; |
| 3334 |
$vc .= '<div class="e2pdf-grid">'; |
| 3335 |
|
| 3336 |
$i = 0; |
| 3337 |
foreach ($meta_keys as $meta_key) { |
| 3338 |
foreach ($meta_key['sub_keys'] as $sub_key) { |
| 3339 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($sub_key . ' (' . $meta_key['meta_key'] . ')', 'e2pdf-wc-order key="' . $meta_key['meta_key'] . '" subkey="' . $sub_key . '" index="0" order_item_meta="true"') . '</div>'; |
| 3340 |
|
| 3341 |
$i++; |
| 3342 |
} |
| 3343 |
} |
| 3344 |
$vc .= '</div>'; |
| 3345 |
} |
| 3346 |
|
| 3347 |
return $vc; |
| 3348 |
} |
| 3349 |
|
| 3350 |
public function get_vm_user() { |
| 3351 |
|
| 3352 |
$vc = '<h3 class="e2pdf-plr5">User</h3>'; |
| 3353 |
$vc .= '<div class="e2pdf-grid">'; |
| 3354 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('ID', 'e2pdf-user key="ID"') . '</div>'; |
| 3355 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Description', 'e2pdf-user key="user_description"') . '</div>'; |
| 3356 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('First Name', 'e2pdf-user key="user_firstname"') . '</div>'; |
| 3357 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Last Name', 'e2pdf-user key="user_lastname"') . '</div>'; |
| 3358 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Login', 'e2pdf-user key="user_login"') . '</div>'; |
| 3359 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Nicename', 'e2pdf-user key="user_nicename"') . '</div>'; |
| 3360 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('E-mail', 'e2pdf-user key="user_email"') . '</div>'; |
| 3361 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Url', 'e2pdf-user key="user_url"') . '</div>'; |
| 3362 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Registered', 'e2pdf-user key="user_registered"') . '</div>'; |
| 3363 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('User Status', 'e2pdf-user key="user_status"') . '</div>'; |
| 3364 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('User Level', 'e2pdf-user key="user_level"') . '</div>'; |
| 3365 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Display Name', 'e2pdf-user key="display_name"') . '</div>'; |
| 3366 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Spam', 'e2pdf-user key="spam"') . '</div>'; |
| 3367 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Deleted', 'e2pdf-user key="deleted"') . '</div>'; |
| 3368 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Locale', 'e2pdf-user key="locale"') . '</div>'; |
| 3369 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Rich Editing', 'e2pdf-user key="rich_editing"') . '</div>'; |
| 3370 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Syntax Highlighting', 'e2pdf-user key="syntax_highlighting"') . '</div>'; |
| 3371 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Use SSL', 'e2pdf-user key="use_ssl"') . '</div>'; |
| 3372 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Roles', 'e2pdf-user key="roles"') . '</div>'; |
| 3373 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Avatar', 'e2pdf-user key="get_avatar"') . '</div>'; |
| 3374 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Avatar Url', 'e2pdf-user key="get_avatar_url"') . '</div>'; |
| 3375 |
$vc .= '</div>'; |
| 3376 |
|
| 3377 |
$meta_keys = $this->get_user_meta_keys(); |
| 3378 |
if (!empty($meta_keys)) { |
| 3379 |
$vc .= '<h3 class="e2pdf-plr5">User Meta Keys</h3>'; |
| 3380 |
$vc .= '<div class="e2pdf-grid">'; |
| 3381 |
$i = 0; |
| 3382 |
foreach ($meta_keys as $meta_key) { |
| 3383 |
$vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-user key="' . $meta_key . '" meta="true"') . '</div>'; |
| 3384 |
$i++; |
| 3385 |
} |
| 3386 |
$vc .= '</div>'; |
| 3387 |
} |
| 3388 |
|
| 3389 |
return $vc; |
| 3390 |
} |
| 3391 |
|
| 3392 |
private function get_user_meta_keys() { |
| 3393 |
global $wpdb; |
| 3394 |
$meta_keys = array(); |
| 3395 |
if ($this->get('item')) { |
| 3396 |
$order_condition = array( |
| 3397 |
'orderby' => 'meta_key', |
| 3398 |
'order' => 'desc', |
| 3399 |
); |
| 3400 |
$orderby = $this->helper->load('db')->prepare_orderby($order_condition); |
| 3401 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare |
| 3402 |
$meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `meta_key` FROM `' . $wpdb->usermeta . '` ' . $orderby . '')); |
| 3403 |
} |
| 3404 |
return $meta_keys; |
| 3405 |
} |
| 3406 |
|
| 3407 |
public function action_e2pdf_wc_cart_template_id() { |
| 3408 |
if (!is_cart() || WC()->cart->is_empty()) { |
| 3409 |
return; |
| 3410 |
} |
| 3411 |
echo apply_filters( |
| 3412 |
'e2pdf_wc_action_e2pdf_wc_cart_template_id', |
| 3413 |
do_shortcode('[e2pdf-download id="' . get_option('e2pdf_wc_cart_template_id', '0') . '" dataset="' . wc_get_page_id('cart') . '" class="button e2pdf-wc-download-button e2pdf-wc-download-cart-button"]') |
| 3414 |
); |
| 3415 |
} |
| 3416 |
|
| 3417 |
public function action_e2pdf_wc_checkout_template_id() { |
| 3418 |
if (!is_checkout() || WC()->cart->is_empty()) { |
| 3419 |
return; |
| 3420 |
} |
| 3421 |
echo apply_filters( |
| 3422 |
'e2pdf_wc_action_e2pdf_wc_checkout_template_id', |
| 3423 |
do_shortcode('[e2pdf-download id="' . get_option('e2pdf_wc_checkout_template_id', '0') . '" dataset="' . wc_get_page_id('cart') . '" class="button e2pdf-wc-download-button e2pdf-wc-download-checkout-button"]') |
| 3424 |
); |
| 3425 |
} |
| 3426 |
|
| 3427 |
public function action_e2pdf_wc_order_details_template_id($order) { |
| 3428 |
$statuses = get_option('e2pdf_wc_order_details_template_id_status', array('any')); |
| 3429 |
if (is_array($statuses) && (in_array($order->get_status(), $statuses, false) || in_array('wc-' . $order->get_status(), $statuses, false) || in_array('any', $statuses, false))) { |
| 3430 |
echo apply_filters( |
| 3431 |
'e2pdf_wc_action_e2pdf_wc_order_details_template_id', |
| 3432 |
do_shortcode('[e2pdf-download id="' . get_option('e2pdf_wc_order_details_template_id', '0') . '" dataset="' . $order->get_id() . '" class="button e2pdf-wc-download-button e2pdf-wc-download-order-details-button"]'), |
| 3433 |
$order |
| 3434 |
); |
| 3435 |
} |
| 3436 |
} |
| 3437 |
|
| 3438 |
public function action_e2pdf_wc_admin_order_actions_template_id($order) { |
| 3439 |
$statuses = get_option('e2pdf_wc_admin_order_actions_template_id_status', array('any')); |
| 3440 |
if (is_array($statuses) && (in_array($order->get_status(), $statuses, false) || in_array('wc-' . $order->get_status(), $statuses, false) || in_array('any', $statuses, false))) { |
| 3441 |
echo apply_filters( |
| 3442 |
'e2pdf_wc_action_e2pdf_wc_admin_order_actions_template_id', |
| 3443 |
do_shortcode('[e2pdf-download id="' . get_option('e2pdf_wc_admin_order_actions_template_id', '0') . '" dataset="' . $order->get_id() . '" user_id="' . $order->get_user_id() . '" class="button e2pdf-wc-download-button e2pdf-wc-download-order-details-button"]'), |
| 3444 |
$order |
| 3445 |
); |
| 3446 |
} |
| 3447 |
} |
| 3448 |
|
| 3449 |
public function action_add_meta_boxes() { |
| 3450 |
add_meta_box( |
| 3451 |
'woocommerce-order-my-custom', |
| 3452 |
'E2Pdf', |
| 3453 |
array($this, 'action_e2pdf_wc_admin_order_details_template_id'), |
| 3454 |
'shop_order', |
| 3455 |
'side', |
| 3456 |
'high' |
| 3457 |
); |
| 3458 |
} |
| 3459 |
|
| 3460 |
public function action_e2pdf_wc_admin_order_details_template_id() { |
| 3461 |
global $post; |
| 3462 |
if (function_exists('wc_get_order') && isset($post->ID)) { |
| 3463 |
$order = wc_get_order($post->ID); |
| 3464 |
if ($order) { |
| 3465 |
$statuses = get_option('e2pdf_wc_admin_order_details_template_id_status', array('any')); |
| 3466 |
if (is_array($statuses) && (in_array($order->get_status(), $statuses, false) || in_array('wc-' . $order->get_status(), $statuses, false) || in_array('any', $statuses, false))) { |
| 3467 |
echo apply_filters( |
| 3468 |
'e2pdf_wc_action_e2pdf_wc_admin_order_details_template_id', |
| 3469 |
do_shortcode('[e2pdf-download id="' . get_option('e2pdf_wc_admin_order_details_template_id', '0') . '" dataset="' . $order->get_id() . '" user_id="' . $order->get_user_id() . '" class="button e2pdf-wc-download-button e2pdf-wc-download-order-details-button"]'), |
| 3470 |
$order |
| 3471 |
); |
| 3472 |
} |
| 3473 |
} |
| 3474 |
} |
| 3475 |
} |
| 3476 |
|
| 3477 |
public function filter_woocommerce_my_account_my_orders_actions($actions, $order) { |
| 3478 |
$statuses = get_option('e2pdf_wc_my_orders_actions_template_id_status', array('any')); |
| 3479 |
if (is_array($statuses) && (in_array($order->get_status(), $statuses, false) || in_array('wc-' . $order->get_status(), $statuses, false) || in_array('any', $statuses, false))) { |
| 3480 |
$url = do_shortcode('[e2pdf-download id="' . get_option('e2pdf_wc_my_orders_actions_template_id', '0') . '" dataset="' . $order->get_id() . '" user_id="' . $order->get_user_id() . '" output="url"]'); |
| 3481 |
if ($url) { |
| 3482 |
$actions['e2pdf_invoice'] = array( |
| 3483 |
'url' => $url, |
| 3484 |
'name' => apply_filters('e2pdf_wc_my_account_my_orders_actions_invoice_title', do_shortcode('[e2pdf-download id="' . get_option('e2pdf_wc_my_orders_actions_template_id', '0') . '" dataset="' . $order->get_id() . '" user_id="' . $order->get_user_id() . '" output="button_title"]')), |
| 3485 |
); |
| 3486 |
} |
| 3487 |
$actions = apply_filters('e2pdf_wc_action_e2pdf_wc_my_orders_actions_template_id', $actions, $order); |
| 3488 |
} |
| 3489 |
return apply_filters('e2pdf_wc_filter_woocommerce_my_account_my_orders_actions', $actions, $order); |
| 3490 |
} |
| 3491 |
|
| 3492 |
/** |
| 3493 |
* Add options for WooCommerce extension |
| 3494 |
* @param array $options - List of options |
| 3495 |
* @return array - Updated options list |
| 3496 |
*/ |
| 3497 |
public function filter_e2pdf_model_options_get_options_options($options = array()) { |
| 3498 |
global $wpdb; |
| 3499 |
|
| 3500 |
$model_e2pdf_template = new Model_E2pdf_Template(); |
| 3501 |
|
| 3502 |
$order_templates = array( |
| 3503 |
'0' => __('--- Select ---', 'e2pdf'), |
| 3504 |
); |
| 3505 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare |
| 3506 |
$templates = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . $model_e2pdf_template->get_table() . '` WHERE extension = %s AND item = %s AND activated = %s ORDER BY ID ASC', 'woocommerce', 'shop_order', '1'), ARRAY_A); |
| 3507 |
if (!empty($templates)) { |
| 3508 |
foreach ($templates as $template) { |
| 3509 |
$order_templates[$template['ID']] = $template['title']; |
| 3510 |
} |
| 3511 |
} |
| 3512 |
|
| 3513 |
$cart_templates = array( |
| 3514 |
'0' => __('--- Select ---', 'e2pdf'), |
| 3515 |
); |
| 3516 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare |
| 3517 |
$templates = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . $model_e2pdf_template->get_table() . '` WHERE extension = %s AND item = %s AND activated = %s ORDER BY ID ASC', 'woocommerce', 'cart', '1'), ARRAY_A); |
| 3518 |
|
| 3519 |
if (!empty($templates)) { |
| 3520 |
foreach ($templates as $template) { |
| 3521 |
$cart_templates[$template['ID']] = $template['title']; |
| 3522 |
} |
| 3523 |
} |
| 3524 |
|
| 3525 |
$options['woocommerce_group'] = array( |
| 3526 |
'name' => 'WooCommerce', |
| 3527 |
'action' => 'extension', |
| 3528 |
'group' => 'woocommerce_group', |
| 3529 |
'options' => array( |
| 3530 |
array( |
| 3531 |
'header' => __('User Order List', 'e2pdf'), |
| 3532 |
'name' => __('Template', 'e2pdf'), |
| 3533 |
'key' => 'e2pdf_wc_my_orders_actions_template_id', |
| 3534 |
'value' => get_option('e2pdf_wc_my_orders_actions_template_id', '0'), |
| 3535 |
'default_value' => '0', |
| 3536 |
'type' => 'select', |
| 3537 |
'options' => $order_templates, |
| 3538 |
), |
| 3539 |
array( |
| 3540 |
'name' => __('Order Status', 'e2pdf'), |
| 3541 |
'key' => 'e2pdf_wc_my_orders_actions_template_id_status', |
| 3542 |
'type' => 'checkbox_list', |
| 3543 |
'options' => $this->get_status_options('e2pdf_wc_my_orders_actions_template_id'), |
| 3544 |
), |
| 3545 |
array( |
| 3546 |
'name' => __('Priority', 'e2pdf'), |
| 3547 |
'key' => 'e2pdf_wc_my_orders_actions_template_id_priority', |
| 3548 |
'value' => get_option('e2pdf_wc_my_orders_actions_template_id_priority', '10'), |
| 3549 |
'default_value' => '10', |
| 3550 |
'type' => 'text', |
| 3551 |
'class' => 'e2pdf-numbers', |
| 3552 |
'placeholder' => '0', |
| 3553 |
), |
| 3554 |
array( |
| 3555 |
'header' => __('User Order Details', 'e2pdf'), |
| 3556 |
'name' => __('Template', 'e2pdf'), |
| 3557 |
'key' => 'e2pdf_wc_order_details_template_id', |
| 3558 |
'value' => get_option('e2pdf_wc_order_details_template_id', '0'), |
| 3559 |
'default_value' => '0', |
| 3560 |
'type' => 'select', |
| 3561 |
'options' => $order_templates, |
| 3562 |
), |
| 3563 |
array( |
| 3564 |
'name' => __('Order Status', 'e2pdf'), |
| 3565 |
'key' => 'e2pdf_wc_order_details_template_id_status', |
| 3566 |
'type' => 'checkbox_list', |
| 3567 |
'options' => $this->get_status_options('e2pdf_wc_order_details_template_id'), |
| 3568 |
), |
| 3569 |
array( |
| 3570 |
'name' => __('Hook', 'e2pdf'), |
| 3571 |
'key' => 'e2pdf_wc_order_details_template_id_hook', |
| 3572 |
'value' => get_option('e2pdf_wc_order_details_template_id_hook', 'woocommerce_order_details_before_order_table'), |
| 3573 |
'default_value' => 'woocommerce_order_details_before_order_table', |
| 3574 |
'type' => 'select', |
| 3575 |
'options' => array( |
| 3576 |
'woocommerce_order_details_before_order_table' => 'woocommerce_order_details_before_order_table', |
| 3577 |
'woocommerce_order_details_before_order_table_items' => 'woocommerce_order_details_before_order_table_items', |
| 3578 |
'woocommerce_order_details_after_order_table_items' => 'woocommerce_order_details_after_order_table_items', |
| 3579 |
'woocommerce_order_details_after_order_table' => 'woocommerce_order_details_after_order_table', |
| 3580 |
'woocommerce_after_order_details' => 'woocommerce_after_order_details', |
| 3581 |
), |
| 3582 |
), |
| 3583 |
array( |
| 3584 |
'name' => __('Priority', 'e2pdf'), |
| 3585 |
'key' => 'e2pdf_wc_order_details_template_id_priority', |
| 3586 |
'value' => get_option('e2pdf_wc_order_details_template_id_priority', '10'), |
| 3587 |
'default_value' => '10', |
| 3588 |
'type' => 'text', |
| 3589 |
'class' => 'e2pdf-numbers', |
| 3590 |
'placeholder' => '0', |
| 3591 |
), |
| 3592 |
array( |
| 3593 |
'header' => __('User Cart', 'e2pdf'), |
| 3594 |
'name' => __('Template', 'e2pdf'), |
| 3595 |
'key' => 'e2pdf_wc_cart_template_id', |
| 3596 |
'value' => get_option('e2pdf_wc_cart_template_id', '0'), |
| 3597 |
'default_value' => '0', |
| 3598 |
'type' => 'select', |
| 3599 |
'options' => $cart_templates, |
| 3600 |
), |
| 3601 |
array( |
| 3602 |
'name' => __('Priority', 'e2pdf'), |
| 3603 |
'key' => 'e2pdf_wc_cart_template_id_priority', |
| 3604 |
'value' => get_option('e2pdf_wc_cart_template_id_priority', '10'), |
| 3605 |
'default_value' => '10', |
| 3606 |
'type' => 'text', |
| 3607 |
'class' => 'e2pdf-numbers', |
| 3608 |
'placeholder' => '0', |
| 3609 |
), |
| 3610 |
array( |
| 3611 |
'header' => __('User Checkout', 'e2pdf'), |
| 3612 |
'name' => __('Template', 'e2pdf'), |
| 3613 |
'key' => 'e2pdf_wc_checkout_template_id', |
| 3614 |
'value' => get_option('e2pdf_wc_checkout_template_id', '0'), |
| 3615 |
'default_value' => '0', |
| 3616 |
'type' => 'select', |
| 3617 |
'options' => $cart_templates, |
| 3618 |
), |
| 3619 |
array( |
| 3620 |
'name' => __('Hook', 'e2pdf'), |
| 3621 |
'key' => 'e2pdf_wc_checkout_template_id_hook', |
| 3622 |
'value' => get_option('e2pdf_wc_checkout_template_id_hook', 'woocommerce_review_order_before_submit'), |
| 3623 |
'default_value' => 'woocommerce_review_order_before_submit', |
| 3624 |
'type' => 'select', |
| 3625 |
'options' => array( |
| 3626 |
'woocommerce_review_order_before_submit' => 'woocommerce_review_order_before_submit', |
| 3627 |
'woocommerce_review_order_after_submit' => 'woocommerce_review_order_after_submit', |
| 3628 |
), |
| 3629 |
), |
| 3630 |
array( |
| 3631 |
'name' => __('Priority', 'e2pdf'), |
| 3632 |
'key' => 'e2pdf_wc_checkout_template_id_priority', |
| 3633 |
'value' => get_option('e2pdf_wc_checkout_template_id_priority', '10'), |
| 3634 |
'default_value' => '10', |
| 3635 |
'type' => 'text', |
| 3636 |
'class' => 'e2pdf-numbers', |
| 3637 |
'placeholder' => '0', |
| 3638 |
), |
| 3639 |
), |
| 3640 |
); |
| 3641 |
|
| 3642 |
/* Deprecate and move to Hooks */ |
| 3643 |
$options['woocommerce_group']['options'][] = array( |
| 3644 |
'header' => __('Admin Order List', 'e2pdf'), |
| 3645 |
'name' => __('Template', 'e2pdf'), |
| 3646 |
'key' => 'e2pdf_wc_admin_order_actions_template_id', |
| 3647 |
'value' => get_option('e2pdf_wc_admin_order_actions_template_id', '0'), |
| 3648 |
'default_value' => '0', |
| 3649 |
'type' => 'select', |
| 3650 |
'options' => $order_templates, |
| 3651 |
); |
| 3652 |
$options['woocommerce_group']['options'][] = array( |
| 3653 |
'name' => __('Hook', 'e2pdf'), |
| 3654 |
'key' => 'e2pdf_wc_admin_order_actions_template_id_hook', |
| 3655 |
'value' => get_option('e2pdf_wc_admin_order_actions_template_id_hook', 'woocommerce_admin_order_actions_end'), |
| 3656 |
'default_value' => 'woocommerce_admin_order_actions_end', |
| 3657 |
'type' => 'select', |
| 3658 |
'options' => array( |
| 3659 |
'woocommerce_admin_order_actions_start' => 'woocommerce_admin_order_actions_start', |
| 3660 |
'woocommerce_admin_order_actions_end' => 'woocommerce_admin_order_actions_end', |
| 3661 |
), |
| 3662 |
); |
| 3663 |
$options['woocommerce_group']['options'][] = array( |
| 3664 |
'name' => __('Order Status', 'e2pdf'), |
| 3665 |
'key' => 'e2pdf_wc_admin_order_actions_template_id_status', |
| 3666 |
'type' => 'checkbox_list', |
| 3667 |
'options' => $this->get_status_options('e2pdf_wc_admin_order_actions_template_id'), |
| 3668 |
); |
| 3669 |
$options['woocommerce_group']['options'][] = array( |
| 3670 |
'name' => __('Priority', 'e2pdf'), |
| 3671 |
'key' => 'e2pdf_wc_admin_order_actions_template_id_priority', |
| 3672 |
'value' => get_option('e2pdf_wc_admin_order_actions_template_id_priority', '10'), |
| 3673 |
'default_value' => '10', |
| 3674 |
'type' => 'text', |
| 3675 |
'class' => 'e2pdf-numbers', |
| 3676 |
'placeholder' => '0', |
| 3677 |
); |
| 3678 |
|
| 3679 |
$options['woocommerce_group']['options'][] = array( |
| 3680 |
'header' => __('Admin Order Details', 'e2pdf'), |
| 3681 |
'name' => __('Template', 'e2pdf'), |
| 3682 |
'key' => 'e2pdf_wc_admin_order_details_template_id', |
| 3683 |
'value' => get_option('e2pdf_wc_admin_order_details_template_id', '0'), |
| 3684 |
'default_value' => '0', |
| 3685 |
'type' => 'select', |
| 3686 |
'options' => $order_templates, |
| 3687 |
); |
| 3688 |
$options['woocommerce_group']['options'][] = array( |
| 3689 |
'name' => __('Order Status', 'e2pdf'), |
| 3690 |
'key' => 'e2pdf_wc_admin_order_details_template_id_status', |
| 3691 |
'type' => 'checkbox_list', |
| 3692 |
'options' => $this->get_status_options('e2pdf_wc_admin_order_details_template_id'), |
| 3693 |
); |
| 3694 |
|
| 3695 |
return $options; |
| 3696 |
} |
| 3697 |
|
| 3698 |
public function get_status_options($key) { |
| 3699 |
$statuses = get_option($key . '_status', array('any')); |
| 3700 |
$order_statuses = array(); |
| 3701 |
if (function_exists('wc_get_order_statuses')) { |
| 3702 |
$order_statuses = wc_get_order_statuses(); |
| 3703 |
} |
| 3704 |
$status_options = array(); |
| 3705 |
foreach ($order_statuses as $order_status_key => $order_status) { |
| 3706 |
$status_options[] = array( |
| 3707 |
'name' => $order_status, |
| 3708 |
'key' => $key . '_status[]', |
| 3709 |
'value' => is_array($statuses) && in_array($order_status_key, $statuses, false) ? $order_status_key : '', |
| 3710 |
'checkbox_value' => $order_status_key, |
| 3711 |
'placeholder' => $order_status, |
| 3712 |
'type' => 'checkbox', |
| 3713 |
'default_value' => '', |
| 3714 |
); |
| 3715 |
} |
| 3716 |
|
| 3717 |
$status_options[] = array( |
| 3718 |
'name' => 'Any', |
| 3719 |
'key' => $key . '_status[]', |
| 3720 |
'value' => is_array($statuses) && in_array('any', $statuses, false) ? 'any' : '', |
| 3721 |
'checkbox_value' => 'any', |
| 3722 |
'placeholder' => __('Any', 'e2pdf'), |
| 3723 |
'type' => 'checkbox', |
| 3724 |
'default_value' => '', |
| 3725 |
); |
| 3726 |
|
| 3727 |
return $status_options; |
| 3728 |
} |
| 3729 |
|
| 3730 |
public function hook_woocommerce_order_edit() { |
| 3731 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_order_edit', 'shop_order'); |
| 3732 |
if (!empty($hooks)) { |
| 3733 |
add_meta_box( |
| 3734 |
'e2pdf', |
| 3735 |
apply_filters('e2pdf_hook_section_title', __('E2Pdf Actions', 'e2pdf'), 'hook_woocommerce_order_edit'), |
| 3736 |
array($this, 'hook_woocommerce_order_edit_callback'), |
| 3737 |
'shop_order', |
| 3738 |
'side', |
| 3739 |
'default', |
| 3740 |
array('hooks' => $hooks) |
| 3741 |
); |
| 3742 |
} |
| 3743 |
} |
| 3744 |
|
| 3745 |
public function hook_woocommerce_order_edit_callback($post, $metabox) { |
| 3746 |
foreach ($metabox['args']['hooks'] as $hook) { |
| 3747 |
if ($this->helper->load('hooks')->process_hook( |
| 3748 |
$hook, |
| 3749 |
[ |
| 3750 |
'dataset' => $post->ID, |
| 3751 |
], |
| 3752 |
'hook_woocommerce_order_edit' |
| 3753 |
) |
| 3754 |
) { |
| 3755 |
$action = apply_filters( |
| 3756 |
'e2pdf_hook_action_button', |
| 3757 |
array( |
| 3758 |
'html' => '<p><a class="e2pdf-download-hook" target="_blank" title="%2$s" href="%1$s"><span class="dashicons dashicons-pdf"></span> %2$s</a></p>', |
| 3759 |
'url' => $this->helper->get_url( |
| 3760 |
array( |
| 3761 |
'page' => 'e2pdf', |
| 3762 |
'action' => 'export', |
| 3763 |
'id' => $hook, |
| 3764 |
'dataset' => $post->ID, |
| 3765 |
), 'admin.php?' |
| 3766 |
), |
| 3767 |
'title' => 'PDF #' . $hook, |
| 3768 |
), 'hook_woocommerce_order_edit', $hook, $post->ID |
| 3769 |
); |
| 3770 |
if (!empty($action)) { |
| 3771 |
echo sprintf( |
| 3772 |
$action['html'], $action['url'], $action['title'] |
| 3773 |
); |
| 3774 |
} |
| 3775 |
} |
| 3776 |
} |
| 3777 |
} |
| 3778 |
|
| 3779 |
public function hook_woocommerce_subscription_edit() { |
| 3780 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_subscription_edit', 'shop_subscription'); |
| 3781 |
if (!empty($hooks)) { |
| 3782 |
add_meta_box( |
| 3783 |
'e2pdf', |
| 3784 |
apply_filters('e2pdf_hook_section_title', __('E2Pdf Actions', 'e2pdf'), 'hook_woocommerce_subscription_edit'), |
| 3785 |
array($this, 'hook_woocommerce_subscription_edit_callback'), |
| 3786 |
'shop_subscription', |
| 3787 |
'side', |
| 3788 |
'default', |
| 3789 |
array('hooks' => $hooks) |
| 3790 |
); |
| 3791 |
} |
| 3792 |
} |
| 3793 |
|
| 3794 |
public function hook_woocommerce_subscription_edit_callback($post, $metabox) { |
| 3795 |
foreach ($metabox['args']['hooks'] as $hook) { |
| 3796 |
if ($this->helper->load('hooks')->process_hook( |
| 3797 |
$hook, |
| 3798 |
[ |
| 3799 |
'dataset' => $post->ID, |
| 3800 |
], |
| 3801 |
'hook_woocommerce_subscription_edit' |
| 3802 |
) |
| 3803 |
) { |
| 3804 |
$action = apply_filters( |
| 3805 |
'e2pdf_hook_action_button', |
| 3806 |
array( |
| 3807 |
'html' => '<p><a class="e2pdf-download-hook" target="_blank" title="%2$s" href="%1$s"><span class="dashicons dashicons-pdf"></span> %2$s</a></p>', |
| 3808 |
'url' => $this->helper->get_url( |
| 3809 |
array( |
| 3810 |
'page' => 'e2pdf', |
| 3811 |
'action' => 'export', |
| 3812 |
'id' => $hook, |
| 3813 |
'dataset' => $post->ID, |
| 3814 |
), 'admin.php?' |
| 3815 |
), |
| 3816 |
'title' => 'PDF #' . $hook, |
| 3817 |
), 'hook_woocommerce_subscription_edit', $hook, $post->ID |
| 3818 |
); |
| 3819 |
if (!empty($action)) { |
| 3820 |
echo sprintf( |
| 3821 |
$action['html'], $action['url'], $action['title'] |
| 3822 |
); |
| 3823 |
} |
| 3824 |
} |
| 3825 |
} |
| 3826 |
} |
| 3827 |
|
| 3828 |
public function hook_woocommerce_order_row_actions($order) { |
| 3829 |
if (!empty($order->id)) { |
| 3830 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_order_row_actions', 'shop_order'); |
| 3831 |
foreach ($hooks as $hook) { |
| 3832 |
if ($this->helper->load('hooks')->process_hook( |
| 3833 |
$hook, |
| 3834 |
[ |
| 3835 |
'dataset' => $order->id, |
| 3836 |
], |
| 3837 |
'hook_woocommerce_order_row_actions' |
| 3838 |
) |
| 3839 |
) { |
| 3840 |
$action = apply_filters( |
| 3841 |
'e2pdf_hook_action_button', |
| 3842 |
array( |
| 3843 |
'html' => '<a class="button e2pdf-download-hook e2pdf-download-hook-icon-button" target="_blank" title="%2$s" href="%1$s">%2$s</a> ', |
| 3844 |
'url' => $this->helper->get_url( |
| 3845 |
array( |
| 3846 |
'page' => 'e2pdf', |
| 3847 |
'action' => 'export', |
| 3848 |
'id' => $hook, |
| 3849 |
'dataset' => $order->id, |
| 3850 |
), 'admin.php?' |
| 3851 |
), |
| 3852 |
'title' => 'PDF #' . $hook, |
| 3853 |
), 'hook_woocommerce_order_row_actions', $hook, $order->id |
| 3854 |
); |
| 3855 |
if (!empty($action)) { |
| 3856 |
echo sprintf( |
| 3857 |
$action['html'], $action['url'], $action['title'] |
| 3858 |
); |
| 3859 |
} |
| 3860 |
} |
| 3861 |
} |
| 3862 |
} |
| 3863 |
} |
| 3864 |
|
| 3865 |
public function hook_woocommerce_order_row_column($columns) { |
| 3866 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_order_row_column', 'shop_order'); |
| 3867 |
if (!empty($hooks)) { |
| 3868 |
$columns['e2pdf_hook_woocommerce_order_row_column'] = apply_filters('e2pdf_hook_section_title', __('E2Pdf Actions', 'e2pdf'), 'hook_woocommerce_order_row_column'); |
| 3869 |
add_action('manage_shop_order_posts_custom_column', array($this, 'hook_woocommerce_order_row_column_callback'), 10, 2); |
| 3870 |
} |
| 3871 |
return $columns; |
| 3872 |
} |
| 3873 |
|
| 3874 |
public function hook_woocommerce_order_row_column_callback($column, $post_id) { |
| 3875 |
if ($column == 'e2pdf_hook_woocommerce_order_row_column') { |
| 3876 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_order_row_column', 'shop_order'); |
| 3877 |
foreach ($hooks as $hook) { |
| 3878 |
if ($this->helper->load('hooks')->process_hook( |
| 3879 |
$hook, |
| 3880 |
[ |
| 3881 |
'dataset' => $post_id, |
| 3882 |
], |
| 3883 |
'hook_woocommerce_order_row_column' |
| 3884 |
) |
| 3885 |
) { |
| 3886 |
$action = apply_filters( |
| 3887 |
'e2pdf_hook_action_button', |
| 3888 |
array( |
| 3889 |
'html' => '<a class="button e2pdf-download-hook e2pdf-download-hook-icon-button" target="_blank" title="%2$s" href="%1$s">%2$s</a> ', |
| 3890 |
'url' => $this->helper->get_url( |
| 3891 |
array( |
| 3892 |
'page' => 'e2pdf', |
| 3893 |
'action' => 'export', |
| 3894 |
'id' => $hook, |
| 3895 |
'dataset' => $post_id, |
| 3896 |
), 'admin.php?' |
| 3897 |
), |
| 3898 |
'title' => 'PDF #' . $hook, |
| 3899 |
), 'hook_woocommerce_order_row_column', $hook, $post_id |
| 3900 |
); |
| 3901 |
if (!empty($action)) { |
| 3902 |
echo sprintf( |
| 3903 |
$action['html'], $action['url'], $action['title'] |
| 3904 |
); |
| 3905 |
} |
| 3906 |
} |
| 3907 |
} |
| 3908 |
} |
| 3909 |
} |
| 3910 |
|
| 3911 |
public function hook_woocommerce_subscription_row_column($columns) { |
| 3912 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_subscription_row_column', 'shop_subscription'); |
| 3913 |
if (!empty($hooks)) { |
| 3914 |
$columns['e2pdf_hook_woocommerce_subscription_row_column'] = apply_filters('e2pdf_hook_section_title', __('E2Pdf Actions', 'e2pdf'), 'hook_woocommerce_subscription_row_column'); |
| 3915 |
add_action('manage_shop_subscription_posts_custom_column', array($this, 'hook_woocommerce_subscription_row_column_callback'), 10, 2); |
| 3916 |
} |
| 3917 |
return $columns; |
| 3918 |
} |
| 3919 |
|
| 3920 |
public function hook_woocommerce_subscription_row_column_callback($column, $post_id) { |
| 3921 |
if ($column == 'e2pdf_hook_woocommerce_subscription_row_column') { |
| 3922 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_subscription_row_column', 'shop_subscription'); |
| 3923 |
foreach ($hooks as $hook) { |
| 3924 |
if ($this->helper->load('hooks')->process_hook( |
| 3925 |
$hook, |
| 3926 |
[ |
| 3927 |
'dataset' => $post_id, |
| 3928 |
], |
| 3929 |
'hook_woocommerce_subscription_row_column' |
| 3930 |
) |
| 3931 |
) { |
| 3932 |
$action = apply_filters( |
| 3933 |
'e2pdf_hook_action_button', |
| 3934 |
array( |
| 3935 |
'html' => '<a class="button e2pdf-download-hook e2pdf-download-hook-icon-button" target="_blank" title="%2$s" href="%1$s">%2$s</a> ', |
| 3936 |
'url' => $this->helper->get_url( |
| 3937 |
array( |
| 3938 |
'page' => 'e2pdf', |
| 3939 |
'action' => 'export', |
| 3940 |
'id' => $hook, |
| 3941 |
'dataset' => $post_id, |
| 3942 |
), 'admin.php?' |
| 3943 |
), |
| 3944 |
'title' => 'PDF #' . $hook, |
| 3945 |
), 'hook_woocommerce_subscription_row_column', $hook, $post_id |
| 3946 |
); |
| 3947 |
if (!empty($action)) { |
| 3948 |
echo sprintf( |
| 3949 |
$action['html'], $action['url'], $action['title'] |
| 3950 |
); |
| 3951 |
} |
| 3952 |
} |
| 3953 |
} |
| 3954 |
} |
| 3955 |
} |
| 3956 |
|
| 3957 |
public function hook_woocommerce_my_account_my_orders_actions($actions, $order) { |
| 3958 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_my_account_my_orders_actions', 'shop_order'); |
| 3959 |
foreach ($hooks as $hook) { |
| 3960 |
if ($this->helper->load('hooks')->process_hook( |
| 3961 |
$hook, |
| 3962 |
[ |
| 3963 |
'dataset' => $order->get_id(), |
| 3964 |
], |
| 3965 |
'hook_woocommerce_my_account_my_orders_actions' |
| 3966 |
) |
| 3967 |
) { |
| 3968 |
$actions['e2pdf_' . $hook] = array( |
| 3969 |
'url' => do_shortcode('[e2pdf-download id="' . $hook . '" dataset="' . $order->get_id() . '" noactions="true" output="url"]'), |
| 3970 |
'name' => apply_filters('e2pdf_wc_my_account_my_orders_actions_invoice_title', do_shortcode('[e2pdf-download id="' . $hook . '" dataset="' . $order->get_id() . '" noactions="true" output="button_title"]')), |
| 3971 |
); |
| 3972 |
} |
| 3973 |
} |
| 3974 |
return apply_filters('e2pdf_wc_filter_woocommerce_my_account_my_orders_actions', $actions, $order); |
| 3975 |
} |
| 3976 |
|
| 3977 |
public function hook_wcs_view_subscription_actions($actions, $order) { |
| 3978 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_wcs_view_subscription_actions', 'shop_subscription'); |
| 3979 |
foreach ($hooks as $hook) { |
| 3980 |
if ($this->helper->load('hooks')->process_hook( |
| 3981 |
$hook, |
| 3982 |
[ |
| 3983 |
'dataset' => $order->get_id(), |
| 3984 |
], |
| 3985 |
'hook_wcs_view_subscription_actions' |
| 3986 |
) |
| 3987 |
) { |
| 3988 |
$actions['e2pdf_' . $hook] = array( |
| 3989 |
'url' => do_shortcode('[e2pdf-download id="' . $hook . '" dataset="' . $order->get_id() . '" noactions="true" output="url"]'), |
| 3990 |
'name' => apply_filters('e2pdf_wc_wcs_view_subscription_actions_actions_title', do_shortcode('[e2pdf-download id="' . $hook . '" dataset="' . $order->get_id() . '" noactions="true" output="button_title"]')), |
| 3991 |
); |
| 3992 |
} |
| 3993 |
} |
| 3994 |
return apply_filters('e2pdf_wc_filter_wcs_view_subscription_actions', $actions, $order); |
| 3995 |
} |
| 3996 |
|
| 3997 |
public function hook_woocommerce_order_details($order) { |
| 3998 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_' . current_action(), 'shop_order'); |
| 3999 |
foreach ($hooks as $hook) { |
| 4000 |
if ($this->helper->load('hooks')->process_hook( |
| 4001 |
$hook, |
| 4002 |
[ |
| 4003 |
'dataset' => $order->get_id(), |
| 4004 |
], |
| 4005 |
'hook_' . current_action() |
| 4006 |
) |
| 4007 |
) { |
| 4008 |
echo do_shortcode('[e2pdf-download id="' . $hook . '" dataset="' . $order->get_id() . '" noactions="true" class="button e2pdf-wc-download-button e2pdf-wc-download-order-details-button"]'); |
| 4009 |
} |
| 4010 |
} |
| 4011 |
} |
| 4012 |
|
| 4013 |
public function hook_woocommerce_subscription_details($order) { |
| 4014 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_' . current_action(), 'shop_subscription'); |
| 4015 |
|
| 4016 |
if (!empty($hooks)) { |
| 4017 |
echo '<tr><td>' . apply_filters('e2pdf_hook_section_title', __('E2Pdf Actions', 'e2pdf'), 'hook_' . current_action()) . '</td><td>'; |
| 4018 |
} |
| 4019 |
|
| 4020 |
foreach ($hooks as $hook) { |
| 4021 |
if ($this->helper->load('hooks')->process_hook( |
| 4022 |
$hook, |
| 4023 |
[ |
| 4024 |
'dataset' => $order->get_id(), |
| 4025 |
], |
| 4026 |
'hook_' . current_action() |
| 4027 |
) |
| 4028 |
) { |
| 4029 |
echo do_shortcode('[e2pdf-download id="' . $hook . '" dataset="' . $order->get_id() . '" noactions="true" class="button e2pdf-wc-download-button e2pdf-wc-download-subscription-details-button"]'); |
| 4030 |
} |
| 4031 |
} |
| 4032 |
|
| 4033 |
if (!empty($hooks)) { |
| 4034 |
echo '</td></tr>'; |
| 4035 |
} |
| 4036 |
} |
| 4037 |
|
| 4038 |
public function hook_woocommerce_proceed_to_checkout() { |
| 4039 |
if (!is_cart() || WC()->cart->is_empty()) { |
| 4040 |
return; |
| 4041 |
} |
| 4042 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_woocommerce_proceed_to_checkout', 'cart'); |
| 4043 |
foreach ($hooks as $hook) { |
| 4044 |
if ($this->helper->load('hooks')->process_hook( |
| 4045 |
$hook, |
| 4046 |
[ |
| 4047 |
'dataset' => wc_get_page_id('cart'), |
| 4048 |
], |
| 4049 |
'hook_woocommerce_proceed_to_checkout' |
| 4050 |
) |
| 4051 |
) { |
| 4052 |
echo do_shortcode('[e2pdf-download id="' . $hook . '" dataset="' . wc_get_page_id('cart') . '" noactions="true" class="button e2pdf-wc-download-button e2pdf-wc-download-cart-button"]'); |
| 4053 |
} |
| 4054 |
} |
| 4055 |
} |
| 4056 |
|
| 4057 |
public function hook_woocommerce_review_order() { |
| 4058 |
if (!is_checkout() || WC()->cart->is_empty()) { |
| 4059 |
return; |
| 4060 |
} |
| 4061 |
$hooks = $this->helper->load('hooks')->get('woocommerce', 'hook_' . current_action(), 'cart'); |
| 4062 |
foreach ($hooks as $hook) { |
| 4063 |
if ( |
| 4064 |
$this->helper->load('hooks')->process_hook( |
| 4065 |
$hook, |
| 4066 |
[ |
| 4067 |
'dataset' => wc_get_page_id('cart'), |
| 4068 |
], |
| 4069 |
'hook_' . current_action() |
| 4070 |
) |
| 4071 |
) { |
| 4072 |
echo do_shortcode('[e2pdf-download id="' . $hook . '" dataset="' . wc_get_page_id('cart') . '" noactions="true" class="button e2pdf-wc-download-button e2pdf-wc-download-checkout-button"]'); |
| 4073 |
} |
| 4074 |
} |
| 4075 |
} |
| 4076 |
} |
| 4077 |
|