From 6f13d8344186c64112b969e647e64d0a6c5dfbe1 Mon Sep 17 00:00:00 2001 From: Michel Velis Date: Sat, 24 Aug 2019 16:16:08 -0400 Subject: [PATCH] Fixed: license values were not been saved inside the woocommerce when saving a product --- includes/slm-meta-boxes.php | 14 ++++++++++---- woocommerce/includes/purchase.php | 12 ++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/includes/slm-meta-boxes.php b/includes/slm-meta-boxes.php index 89c20cf..80e2e6f 100644 --- a/includes/slm-meta-boxes.php +++ b/includes/slm-meta-boxes.php @@ -6,9 +6,9 @@ // from: https://gist.github.com/JeroenSormani/6b710d079386d096f932 add_filter('woocommerce_product_data_tabs', 'wc_slm_add_tab'); -add_action('woocommerce_process_product_meta_simple', 'wc_slm_save_data'); +add_action('woocommerce_process_product_meta', 'wc_slm_save_data'); add_action('woocommerce_product_data_panels', 'wc_slm_data_panel'); -add_filter('product_type_options', 'add_wc_slm_data_tab_enabled_product_option'); +//add_filter('product_type_options', 'add_wc_slm_data_tab_enabled_product_option'); //legacy add_action('init', 'slm_register_product_type'); add_filter('product_type_selector', 'slm_add_product_type'); add_action('admin_footer', 'slm_license_admin_custom_js'); @@ -44,7 +44,7 @@ function wcpp_custom_style() var is_wc_slm_data_tab_enabled = jQuery('input#_wc_slm_data_tab_enabled:checked').size(); // console.log( is_wc_slm_data_tab_enabled ); - $jQuery('.show_if_wc_slm_data_tab_enabled').hide(); + jQuery('.show_if_wc_slm_data_tab_enabled').hide(); jQuery('.hide_if_wc_slm_data_tab_enabled').hide(); if (is_wc_slm_data_tab_enabled) { jQuery('.hide_if_wc_slm_data_tab_enabled').hide(); @@ -158,6 +158,12 @@ function wc_slm_data_panel() /** Hook callback function to save custom fields information */ function wc_slm_save_data($post_id) { + // _domain_licenses + // _devices_licenses + // _license_type + // _license_current_version + // _license_until_version + $_domain_licenses = $_POST['_domain_licenses']; if (!empty($_domain_licenses)) { update_post_meta($post_id, '_domain_licenses', esc_attr($_domain_licenses)); @@ -207,7 +213,7 @@ public function __construct($product) function slm_add_product_type($types) { - $types['slm_license'] = __('License product', 'slm_license'); + $types['slm_license'] = __('License product', 'softwarelicensemanager'); return $types; } function slm_license_admin_custom_js() diff --git a/woocommerce/includes/purchase.php b/woocommerce/includes/purchase.php index b64f6dc..c5ebd22 100755 --- a/woocommerce/includes/purchase.php +++ b/woocommerce/includes/purchase.php @@ -216,12 +216,12 @@ function wc_slm_payment_note($order_id, $licenses) { $license_key = $license['key']; $message .= '
' . $license['item'] . ': ' . $license_key . ''; - add_post_meta($order_id, 'slm_wc_license_order_key', $license_key); - add_post_meta($order_id, 'slm_wc_license_expires', $license[ 'expires']); - add_post_meta($order_id, 'slm_wc_license_type', $license[ 'type']); - add_post_meta($order_id, 'slm_wc_license_status', $license['status']); - add_post_meta($order_id, 'slm_wc_license_version', $license[ 'version']); - add_post_meta($order_id, 'slm_wc_until_version', $license['until']); + add_post_meta($order_id, 'slm_wc_license_order_key', $license_key); + add_post_meta($order_id, 'slm_wc_license_expires', $license[ 'expires']); + add_post_meta($order_id, 'slm_wc_license_type', $license[ 'type']); + add_post_meta($order_id, 'slm_wc_license_status', $license['status']); + add_post_meta($order_id, 'slm_wc_license_version', $license[ 'version']); + add_post_meta($order_id, 'slm_wc_until_version', $license['until']); //SLM_Helper_Class::write_log($license_key); }