Skip to content

Instantly share code, notes, and snippets.

/**
* 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);
});
// Print
var Client = require('node-rest-client').Client;
var client = new Client();
var args = {
data: {
"command": "select",
"print": true
},
// 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);
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 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...');
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name
www.mysite.com
mysite.com
;
ssl on;
<p style="padding-bottom: 100px;">area 1</p>
<p style="padding-bottom: 100px;">area 2</p>
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;
}
add_filter( 'submit_job_form_fields', 'remove_cat_field' );
function remove_cat_field( $fields ) {
unset( $fields['job']['job_category'] );
return $fields;
}
@bryceadams
bryceadams / gist:d6b853049e4b6ddc6365
Last active August 29, 2015 14:20
WooCommerce Drip - Handle subscription / adding custom fields when order set to completed. This does not take into account the user's subscribe selection during checkout, and actually should be used instead of the subscribe checkbox.
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;