This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub httpRequestDeactivate() | |
'Use to deactivate license. Mostly the same as httpRequestActivate but without the check for if the max number of activations has been reached. | |
Dim oRequest As Object | |
Const cUrl As String = "https://yoursite.com/?edd_action=deactivate_license&item_name=Name of the Download Product&license=" | |
URL = cUrl & ThisWorkbook.Worksheets("Sheet1").Range("A1").Value | |
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1") | |
oRequest.Open "GET", URL | |
oRequest.Send |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub httpRequestActivate() | |
'Run the httpRequestCheck to see if the license has used up all of the activations it had available. | |
'If it has we add in_use to cell A5 so that we can avoid allowing the license to be activated on more computers than our license allows. | |
'Note after the first activation, the license will return as valid before the end of the license expiration even if it has been deactivated so we need to check for remaining activations this way as well. | |
httpRequestCheck | |
With ThisWorkbook.Worksheets("Sheet1").Range("A1") | |
If .Cells(4, 1).Value = 0 Then | |
'Cells(4, 1).Value is the number of activations remaining. In my case there will only be 1 or 0 but even if you allow more than one activation, 0 is where we should stop allowing it to be activated. | |
'This indicates that the license is in use on as many computers as the license will allow. We will check for this later. | |
.Cells(5, 1).Value = "in_use" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'json response from Software Licensing in the following format | |
'{"success":true,"license":"valid","item_name":"Download Product Name","expires":"lifetime","payment_id":"54224","customer_name":"John Doe","customer_email":"john@sample.com","license_limit":1,"site_count":1,"activations_left":0} | |
Sub httpRequestCheck() | |
'use to check license once when workbook opens | |
Dim oRequest As Object | |
Const cUrl As String = "https://yoursite.com/?edd_action=check_license&item_name=Name of the Download Product&license=" | |
URL = cUrl & ThisWorkbook.Worksheets("Sheet1").Range("A1").Value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://YOURSITE.com/?edd_action={request type}&item_name=EDD+Product+Name&license=cc22c1ec86304b36883440e2e84cddff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub userform_initialize() | |
With ThisWorkbook.Worksheets("Sheet1").Range("A1") | |
license.Value = .Cells(1, 1).Value | |
Label2.Caption = "Your license key is " & .Cells(3, 1).Value & " and has " & .Cells(4, 1).Value & " activations remaining." | |
End With | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remove_filter( 'woocommerce_default_address_fields', 'get_default_address_fields', 10, 1 ); | |
add_filter( 'woocommerce_default_address_fields', 'updated_get_default_address_fields', 10, 1 ); | |
function updated_get_default_address_fields() { | |
global $woocommerce; | |
$fields = array( | |
'first_name' => array( | |
'label' => __( 'First Name', 'woocommerce' ), | |
'required' => true, | |
'class' => array( 'form-row-first' ), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// WooCommerce Checkout Fields Hook | |
add_filter( 'woocommerce_checkout_fields' , 'custom_wc_checkout_fields' ); | |
// Change order comments placeholder and label, and set billing phone number to not required. | |
function custom_wc_checkout_fields( $fields ) { | |
$fields['order']['order_comments']['placeholder'] = 'Enter your placeholder text here.'; | |
$fields['order']['order_comments']['label'] = 'Enter your label here.'; | |
$fields['billing']['billing_phone']['required'] = false; | |
return $fields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the field to order emails | |
**/ | |
add_filter( 'woocommerce_email_order_meta_keys', 'some_order_meta_keys' ); | |
function some_order_meta_keys() { | |
if (get_post_meta( get_the_ID(), 'Some Field')) { | |
echo 'This is the custom information you entered in Some Field: ' . get_post_meta( get_the_ID(), 'Some Field', true) . '<br />'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Update the order meta with field value | |
*/ | |
add_action( 'woocommerce_checkout_update_order_meta', 'some_custom_checkout_field_update_order_meta' ); | |
function some_custom_checkout_field_update_order_meta( $order_id ) { | |
if ( ! empty( $_POST['some_field_name'] ) ) { | |
update_post_meta( $order_id, 'Some Field', sanitize_text_field( $_POST['some_field_name'] ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Process the checkout | |
*/ | |
add_action('woocommerce_checkout_process', 'some_custom_checkout_field_process'); | |
function some_custom_checkout_field_process() { | |
// Check if the field is set, if not then show an error message. | |
if ( ! $_POST['some_field_name'] ) | |
wc_add_notice( __( 'Please enter something here.' ), 'error' ); |