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
/** | |
* Start the server. | |
*/ | |
var server = app.listen(80, function () { | |
var host = '127.0.0.1'; | |
var port = '80'; | |
console.log('Woo 3D Print listening at http://%s:%s', host, port); | |
}); |
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
var Client = require('node-rest-client').Client; | |
var client = new Client(); | |
var args = { | |
data: { | |
"command": "select", | |
"print": true | |
}, |
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
// Get the order's first item | |
var line_items = webhookBody.order.line_items; | |
var item1 = line_items[0]; | |
var itemName = item1.name.replace(/ /g,"_"); | |
console.log(itemName); |
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
var secret = '3d' | |
var data = _json.stringify(webhookBody); | |
var signature = crypto.createHmac('sha256', secret).update(data).digest('base64'); | |
// Check the webhook signature | |
if (webhookSignature !== signature) { | |
console.log('Access denied - invalid signature'); | |
return res.send('access denied', 'invalid signature', null, 403); | |
} |
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
/** | |
* This is the endpoint WC needs to post through a webhook to, | |
* when a new sale has been made. | |
*/ | |
app.post('/print', function (req, res) { | |
var webhookBody = req.body || {}; | |
var webhookSignature = req.headers['x-wc-webhook-signature']; | |
console.log('Receiving webhook...'); |
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
server { | |
listen 443 ssl; | |
listen [::]:443 ssl; | |
server_name | |
www.mysite.com | |
mysite.com | |
; | |
ssl on; |
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
<p style="padding-bottom: 100px;">area 1</p> | |
<p style="padding-bottom: 100px;">area 2</p> |
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
add_filter( 'submit_job_form_fields', 'default_cat_field' ); | |
function default_cat_field( $fields ) { | |
$fields['job']['job_category']['default'] = 22; // this needs to the default category ID | |
return $fields; | |
} |
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
add_filter( 'submit_job_form_fields', 'remove_cat_field' ); | |
function remove_cat_field( $fields ) { | |
unset( $fields['job']['job_category'] ); | |
return $fields; | |
} |
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
add_action( 'woocommerce_order_status_completed', 'drip_subscribe_user_to_campaign', 20, 1 ); | |
add_action( 'woocommerce_order_status_completed', 'drip_add_user_fields', 30, 1 ); | |
function drip_subscribe_user_to_campaign( $order_id ) { | |
$WC_Drip_Settings = new WC_Drip_Settings(); | |
$wrapper = $WC_Drip_Settings->wrapper(); | |
$order = wc_get_order( $order_id ); | |
$email = $order->billing_email; |