Skip to content

Commit

Permalink
Fixed: license values were not been saved inside the woocommerce when…
Browse files Browse the repository at this point in the history
… saving a product
  • Loading branch information
michelve committed Aug 24, 2019
1 parent ca8634c commit 6f13d83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
14 changes: 10 additions & 4 deletions includes/slm-meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions woocommerce/includes/purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ function wc_slm_payment_note($order_id, $licenses) {
$license_key = $license['key'];
$message .= '<br />' . $license['item'] . ': <a href="'. get_admin_url() . 'admin.php?page=slm_manage_license&edit_record=' . wc_slm_get_license_id($license_key).'">' . $license_key . '</a>';

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);
}
Expand Down

0 comments on commit 6f13d83

Please sign in to comment.