no message

This commit is contained in:
Michel Velis 2018-11-27 22:51:29 -05:00
parent 1bd62f9079
commit cbdb6058fb
56 changed files with 211 additions and 88 deletions

0
.gitignore vendored Normal file → Executable file
View file

0
CHANGELOG.md Normal file → Executable file
View file

0
LICENSE.md Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

0
TODO.md Normal file → Executable file
View file

0
software-license-manager/LICENSE.md Normal file → Executable file
View file

View file

View file

@ -32,17 +32,14 @@ function wc_slm_on_complete_purchase($order_id) {
*/
function wc_slm_create_license_keys($order_id) {

$_order = new WC_Order($order_id);
$order_id = new WC_Order( $order_id );

// write_log('order info '. $order_id);
// die();
$_order = new WC_Order($order_id);
$order_id = new WC_Order( $order_id );

global $purchase_id;
$purchase_id_ = $order_id->id;
$user_id = $_order->get_user_id();
$user_info = get_userdata($user_id);
$get_user_meta = get_user_meta($user_id);
$purchase_id_ = $order_id->id;
$user_id = $_order->get_user_id();
$user_info = get_userdata($user_id);
$get_user_meta = get_user_meta($user_id);
$payment_meta['user_info']['first_name'] = $get_user_meta['billing_first_name'][0];
$payment_meta['user_info']['last_name'] = $get_user_meta['billing_last_name'][0];
$payment_meta['user_info']['email'] = $get_user_meta['billing_email'][0];
@ -52,6 +49,7 @@ function wc_slm_create_license_keys($order_id) {
$licenses = array();
$items = $_order->get_items();


foreach ($items as $item => $values) {
$download_id = $product_id = $values['product_id'];
$product = new WC_Product($product_id);
@ -123,47 +121,33 @@ function wc_slm_create_license_keys($order_id) {

// Build parameters
$api_params = array();
$api_params['slm_action'] = 'slm_create_new';
$api_params['secret_key'] = KEY_API;
$api_params['first_name'] = (isset($payment_meta['user_info']['first_name'])) ? $payment_meta['user_info']['first_name'] : '';
$api_params['last_name'] = (isset($payment_meta['user_info']['last_name'])) ? $payment_meta['user_info']['last_name'] : '';
$api_params['email'] = (isset($payment_meta['user_info']['email'])) ? $payment_meta['user_info']['email'] : '';
$api_params['company_name'] = $payment_meta['user_info']['company'];
$api_params['purchase_id_'] = $purchase_id_;
$api_params['product_ref'] = '16';

/**
* set product id as txn
* @since 1.0.2
* can be set to order id by $order_id var instead of $product_id
* @since 1.0.7 txn_id change from $product_id to $order_id
* @ref https://wordpress.org/support/topic/qty-1-generates-same-license
*/
$api_params['txn_id'] = $purchase_id_;
// $api_params['max_allowed_domains'] = $sites_allowed; //unique per product
$api_params['max_allowed_domains'] = $amount_of_licenses; //unique per product
$api_params['max_allowed_devices'] = $amount_of_licenses_devices; //unique per product
$api_params['slm_action'] = 'slm_create_new';
$api_params['secret_key'] = KEY_API;
$api_params['first_name'] = (isset($payment_meta['user_info']['first_name'])) ? $payment_meta['user_info']['first_name'] : '';
$api_params['last_name'] = (isset($payment_meta['user_info']['last_name'])) ? $payment_meta['user_info']['last_name'] : '';
$api_params['email'] = (isset($payment_meta['user_info']['email'])) ? $payment_meta['user_info']['email'] : '';
$api_params['company_name'] = $payment_meta['user_info']['company'];
$api_params['purchase_id_'] = $purchase_id_;
$api_params['product_ref'] = $product_id; // TODO: get product id
$api_params['txn_id'] = $purchase_id_;
$api_params['max_allowed_domains'] = $amount_of_licenses;
$api_params['max_allowed_devices'] = $amount_of_licenses_devices;
$api_params['date_created'] = date('Y-m-d');
$api_params['date_expiry'] = $renewal_period;

// Send query to the license manager server
$url = 'http://' . WOO_SLM_API_URL . '?' . http_build_query($api_params);
$url = str_replace(array('http://', 'https://'), '', $url);
$url = 'http://' . $url;
$response = wp_remote_get($url, array('timeout' => 20, 'sslverify' => false));
$license_key = wc_slm_get_license_key($response);
$url = 'http://' . WOO_SLM_API_URL . '?' . http_build_query($api_params);
$url = str_replace(array('http://', 'https://'), '', $url);
$url = 'http://' . $url;
$response = wp_remote_get($url, array('timeout' => 20, 'sslverify' => false));
$license_key = wc_slm_get_license_key($response);

// Collect license keys
if ($license_key) {
$licenses[] = array(
'item' => $item_name,
'key' => $license_key,
/**
* Add Expire Date
* @since 1.0.7
* @author AvdP (Albert van der Ploeg)
*/
'expires' => $renewal_period,
'item' => $item_name,
'key' => $license_key,
'expires' => $renewal_period,
);
}
}
@ -213,12 +197,11 @@ function wc_slm_payment_note($order_id, $licenses) {

if ($licenses && count($licenses) != 0) {
$message = __('License Key(s) generated', 'wc-slm');

foreach ($licenses as $license) {

$message .= '<br />' . $license['item'] . ': ' . $license['key'];
}
} else {
}
else {
$message = __('License Key(s) could not be created.', 'wc-slm');
}

@ -228,10 +211,7 @@ function wc_slm_payment_note($order_id, $licenses) {

/**
* Assign generated license keys to payments
*
* @since 1.0.0
* @return void
*/
*/
function wc_slm_assign_licenses($order_id, $licenses) {

if (count($licenses) != 0) {
@ -311,35 +291,3 @@ function wc_get_payment_transaction_id($order_id) {
return get_post_meta($order_id, '_transaction_id', true);
}

/**
* add license details to user account details
* @since 1.0.3
*/
//add_action('woocommerce_order_details_after_order_table', 'wc_slm_lic_order_meta', 10, 1);

function wc_slm_lic_order_meta($order) {
$licenses = get_post_meta($order->post->ID, '_wc_slm_payment_licenses', true);

if ($licenses && count($licenses) != 0) {
$output = '<h3>' . __('Your Licenses', 'wc-slm') . ':</h3><table class="shop_table shop_table_responsive"><tr><th class="td">' . __('Item', 'wc-slm') . '</th><th class="td">' . __('License', 'wc-slm') . '</th></tr>';
foreach ($licenses as $license) {
$output .= '<tr>';
if (isset($license['item']) && isset($license['key'])) {

if ($output) {
$output .= '<br />';
}
$output .= '<td class="td">' . $license['item'] . '</td>';
$output .= '<td class="td">' . $license['key'] . '</td>';
} else {
$output .= 'No item and key assigned';
}
$output .= '</tr>';
}
$output .= '</table>';
}

if (isset($output)) {
echo $output;
}
}

View file

View file

@ -1,7 +1,9 @@
<?php

/* * ********************************* */
/* * * WP eStore Plugin Integration ** */
/* * ********************************* */

add_filter('eStore_notification_email_body_filter', 'slm_handle_estore_email_body_filter', 10, 3); //Standard sale notification email
add_filter('eStore_squeeze_form_email_body_filter', 'slm_handle_estore_email_body_filter', 10, 3); //Squeeze form email
function slm_handle_estore_email_body_filter($body, $payment_data, $cart_items) {

0
software-license-manager/admin/index.html Normal file → Executable file
View file

0
software-license-manager/admin/slm-add-licenses.php Normal file → Executable file
View file

0
software-license-manager/admin/slm-admin-functions.php Normal file → Executable file
View file

0
software-license-manager/admin/slm-admin-init.php Normal file → Executable file
View file

View file

10
software-license-manager/admin/slm-lic-settings.php Normal file → Executable file
View file

@ -41,6 +41,7 @@ function wp_lic_mgr_general_settings() {
'enable_debug' => isset($_POST['enable_debug']) ? '1':'',
'slm_woo' => isset($_POST['slm_woo']) ? '1':'',
'slm_subscriptio' => isset($_POST['slm_subscriptio']) ? '1':'',
'slm_wpestores' => isset($_POST['slm_wpestores']) ? '1':'',
);
update_option('slm_plugin_options', $options);

@ -138,8 +139,15 @@ function wp_lic_mgr_general_settings() {
<input name="slm_subscriptio" type="checkbox"<?php if ($options['slm_subscriptio'] != '') echo ' checked="checked"'; ?> value="1"/>

<br />Subscriptio is a WooCommerce extension that allows you to sell subscriptions. Subscriptio adds recurring payments capability to WooCommerce so you can sell products like magazine subscriptions, online memberships, e-learning packages and any other tangible or intangible products. <a href="https://codecanyon.net/item/subscriptio-woocommerce-subscriptions/8754068">Learn More</a></td>
</tr>
</tr
<tr valign="top">
<th scope="row">WP eStores Support</th>
<td>
<input name="slm_wpestores" type="checkbox"<?php if ($options['slm_wpestores'] != '') echo ' checked="checked"'; ?> value="1"/> <br>
WordPress eStore Plugin Complete Solution to Sell Digital Products from Your WordPress Blog Securely

</td>
</tr>




View file

0
software-license-manager/admin/slm-manage-licenses.php Normal file → Executable file
View file

0
software-license-manager/includes/index.php Normal file → Executable file
View file

0
software-license-manager/includes/slm-api-listener.php Normal file → Executable file
View file

0
software-license-manager/includes/slm-api-utility.php Normal file → Executable file
View file

0
software-license-manager/includes/slm-debug-logger.php Normal file → Executable file
View file

0
software-license-manager/includes/slm-error-codes.php Normal file → Executable file
View file

View file

160
software-license-manager/includes/slm-meta-boxes.php Normal file → Executable file
View file

@ -61,4 +61,162 @@ function save_variation_fields( $variation_id, $i) {
$text_field = stripslashes( $_POST['amount_of_licenses_devices'][$i] );
update_post_meta( $variation_id, 'amount_of_licenses_devices', esc_attr( $text_field ) );

}
}






























// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'License', 'woocommerce' ),
'target' => 'my_custom_product_data',
'class' => array( 'show_if_simple', 'show_if_variable' ),
);
return $product_data_tabs;
}





// functions you can call to output text boxes, select boxes, etc.
add_action('woocommerce_product_data_panels', 'woocom_custom_product_data_fields');

function woocom_custom_product_data_fields() {
global $post;

// Note the 'id' attribute needs to match the 'target' parameter set above
?> <div id = 'my_custom_product_data'
class = 'panel woocommerce_options_panel' > <?php
?> <div class = 'options_group' > <?php
// Text Field
woocommerce_wp_text_input(
array(
'id' => 'amount_of_licenses_devices',
'label' => __( 'Amount of devices', 'woocommerce' ),
'wrapper_class' => 'show_if_simple', //show_if_simple or show_if_variable
'placeholder' => 'Custom text field',
'desc_tip' => 'true',
'description' => __( 'Enter the custom value here.', 'woocommerce' )
)
);

// Number Field
woocommerce_wp_text_input(
array(
'id' => '_number_field',
'label' => __( 'Custom Number Field', 'woocommerce' ),
'placeholder' => '',
'description' => __( 'Enter the custom value here.', 'woocommerce' ),
'type' => 'number',
'custom_attributes' => array(
'step' => 'any',
'min' => '15'
)
)
);

// Checkbox
woocommerce_wp_checkbox(
array(
'id' => '_checkbox',
'label' => __('Custom Checkbox Field', 'woocommerce' ),
'description' => __( 'Check me!', 'woocommerce' )
)
);

// Select
woocommerce_wp_select(
array(
'id' => '_select',
'label' => __( 'Custom Select Field', 'woocommerce' ),
'options' => array(
'one' => __( 'Custom Option 1', 'woocommerce' ),
'two' => __( 'Custom Option 2', 'woocommerce' ),
'three' => __( 'Custom Option 3', 'woocommerce' )
)
)
);

// Textarea
woocommerce_wp_textarea_input(
array(
'id' => '_textarea',
'label' => __( 'Custom Textarea', 'woocommerce' ),
'placeholder' => '',
'description' => __( 'Enter the value here.', 'woocommerce' )
)
);
?> </div>

</div><?php
}

/** Hook callback function to save custom fields information */
function woocom_save_proddata_custom_fields($post_id) {
// Save Text Field
$text_field = $_POST['_text_field'];
if (!empty($text_field)) {
update_post_meta($post_id, '_text_field', esc_attr($text_field));
}

// Save Number Field
$number_field = $_POST['_number_field'];
if (!empty($number_field)) {
update_post_meta($post_id, '_number_field', esc_attr($number_field));
}
// Save Textarea
$textarea = $_POST['_textarea'];
if (!empty($textarea)) {
update_post_meta($post_id, '_textarea', esc_html($textarea));
}

// Save Select
$select = $_POST['_select'];
if (!empty($select)) {
update_post_meta($post_id, '_select', esc_attr($select));
}

// Save Checkbox
$checkbox = isset($_POST['_checkbox']) ? 'yes' : 'no';
update_post_meta($post_id, '_checkbox', $checkbox);

// Save Hidden field
$hidden = $_POST['_hidden_field'];
if (!empty($hidden)) {
update_post_meta($post_id, '_hidden_field', esc_attr($hidden));
}
}

add_action( 'woocommerce_process_product_meta_simple', 'woocom_save_proddata_custom_fields' );

// You can uncomment the following line if you wish to use those fields for "Variable Product Type"
//add_action( 'woocommerce_process_product_meta_variable', 'woocom_save_proddata_custom_fields' );

0
software-license-manager/includes/slm-utility.php Normal file → Executable file
View file

17
software-license-manager/includes/slm_plugin_core.php Normal file → Executable file
View file

@ -70,7 +70,6 @@ include_once( SLM_LIB .'slm-utility.php');
include_once( SLM_LIB .'slm-init-time-tasks.php');
include_once( SLM_LIB .'slm-api-utility.php');
include_once( SLM_LIB .'slm-api-listener.php');
include_once( SLM_LIB .'slm-third-party-integration.php');

// Front end-menu
// TODO check for optional plugins
@ -78,18 +77,24 @@ include_once( SLM_LIB .'slm-third-party-integration.php');
// Third Party Support
if (null !== SLM_Helper_Class::slm_get_option('slm_woo') && SLM_Helper_Class::slm_get_option('slm_woo') == 1) {
include_once( SLM_PUBLIC . 'slm-add-menu-frontend.php');

// WordPress Plugin :: wc-software-license-manager
include_once( SLM_ADMIN . 'includes/woocommerce/wc-software-license-manager.php');

// support for meta boxes (variations only, this can be applied to single prodicts as well)
include_once( SLM_LIB . 'slm-meta-boxes.php');
}

if (null !== SLM_Helper_Class::slm_get_option('slm_subscriptio') && SLM_Helper_Class::slm_get_option('slm_subscriptio') == 1) {
// Subscriptio PLugin Intergration
// TODO - check for plugin exist
include_once( SLM_LIB . 'slm-subscriptio.php');
include_once( SLM_ADMIN . 'includes/subscriptio/slm-subscriptio.php');
}

if (null !== SLM_Helper_Class::slm_get_option('slm_wpestores') && SLM_Helper_Class::slm_get_option('slm_wpestores') == 1) {
// wpestores PLugin Intergration
include_once( SLM_ADMIN . 'includes/wpestores/slm-wpestores.php');
}

// support for meta boxes (variations only, this can be applied to single prodicts as well)
include_once( SLM_LIB . 'slm-meta-boxes.php');

//Include admin side only files
if (is_admin()) {
@ -112,6 +117,7 @@ function slm_init_handler() {
$init_task = new SLM_Init_Time_Tasks();
$api_listener = new SLM_API_Listener();
}

//Do plugins loaded time tasks
function slm_plugins_loaded_handler() {
//Runs when plugins_loaded action gets fired
@ -123,6 +129,7 @@ function slm_plugins_loaded_handler() {
}
}
}

//TODO - need to move this to an ajax handler file
function slm_del_reg_dom() {
global $wpdb;

0
software-license-manager/index.php Normal file → Executable file
View file

0
software-license-manager/public/assets/css/jquery-ui.css vendored Normal file → Executable file
View file

0
software-license-manager/public/assets/css/slm.css Normal file → Executable file
View file

View file

Before

Width:  |  Height:  |  Size: 249 KiB

After

Width:  |  Height:  |  Size: 249 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 272 KiB

After

Width:  |  Height:  |  Size: 272 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 354 KiB

After

Width:  |  Height:  |  Size: 354 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 352 KiB

After

Width:  |  Height:  |  Size: 352 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 349 KiB

After

Width:  |  Height:  |  Size: 349 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Before After
Before After

0
software-license-manager/public/assets/images/bg.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 600 B

After

Width:  |  Height:  |  Size: 600 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 698 B

After

Width:  |  Height:  |  Size: 698 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1,020 B

After

Width:  |  Height:  |  Size: 1,020 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

0
software-license-manager/public/assets/js/index.html Normal file → Executable file
View file

View file

View file

0
software-license-manager/software-license-manager.php Normal file → Executable file
View file

0
software-license-manager/uninstall.php Normal file → Executable file
View file