This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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":"[email protected]","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 hidden or 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 hidden or 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 hidden or 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 Activate_License() | |
'Show the license key activation UserForm (mine is creatively named LicenseKey) | |
LicenseKey.Show | |
End Sub |
This file contains hidden or 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 Workbook_Open() | |
httpRequestCheck | |
With ThisWorkbook.Worksheets("Sheet1").Range("A1") | |
' the And .Cells(4, 1) = 0 is probably redundant, and if you are allowing more than one activation per license key you should remove that part. | |
If .Cells(3, 1).Value = "valid" And .Cells(4, 1) = 0 And .Cells(5, 1) <> "in_use" Then | |
'call your add-in here | |
Else | |
'if the license is not valid, the number of activations remaining is greater than 0, and it is not in use elsewhere we should display the license activation UserForm. | |
Activate_License | |
End If |
This file contains hidden or 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 LicenseKeyActivate_Click() | |
'license.Value is what the user entered into the text box on the UserForm. | |
If license.Value = "" Then | |
MsgBox "Please enter a license key.", vbExclamation, "Input Data" | |
Exit Sub | |
Else | |
Application.ScreenUpdating = False | |
With ThisWorkbook.Worksheets("Sheet1").Range("A1") | |
.Cells(1, 1).Value = license.Value |
This file contains hidden or 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 LicenseKeyDeactivate_Click() | |
If license.Value = "" Then | |
MsgBox "Please enter a license key.", vbExclamation, "Input Data" | |
Exit Sub | |
Else | |
Application.ScreenUpdating = False | |
With ThisWorkbook.Worksheets("Sheet1").Range("A1") | |
.Cells(1, 1).Value = license.Value |