Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
danielbitzer / functions.php
Created December 29, 2017 12:41
AutomateWoo Refer A Friend - Change number of fields in share form (requires v1.7.10)
<?php
add_filter( 'automatewoo/referrals/share_form/email_field_count', function() {
return 3;
});
@danielbitzer
danielbitzer / functions.php
Created December 22, 2017 14:07
WooCommerce Checkout - Make the email field appear first
<?php
// Minimum version WC 3.0
add_filter( 'woocommerce_checkout_fields', 'my_filter_woocommerce_checkout_fields');
function my_filter_woocommerce_checkout_fields($fields) {
$fields['billing']['billing_email']['priority'] = 5;
$fields['billing']['billing_email']['class'] = array( 'form-row-wide' );
return $fields;
}
@danielbitzer
danielbitzer / functions.php
Created December 15, 2017 11:08
AutomateWoo - Set custom reply to for workflow emails
<?php
/**
* @since 3.4.3
*/
add_filter( 'automatewoo/workflow/mailer', 'my_filter_automatewoo_workflow_mailer' );
/**
* @param AutomateWoo\Mailer $mailer
* @return AutomateWoo\Mailer
@danielbitzer
danielbitzer / functions.php
Created December 6, 2017 18:50
AutomateWoo - Include custom order statuses in the customer last order date calculation, this applies to the customer win back trigger
<?php
add_filter( 'automatewoo/customer/last_order_date_statuses', function( $statuses ){
$statuses[] = 'my-custom-status';
return $statuses;
});
@danielbitzer
danielbitzer / functions.php
Created November 11, 2017 15:35
AutomateWoo - Add email restriction to uniquely generated workflow coupons
<?php
// added in v3.3.3
add_filter( 'automatewoo/variables/coupons/use_email_restriction', '__return_true' );
@danielbitzer
danielbitzer / functions.php
Created October 5, 2017 09:59
AutomateWoo - Change workflow generated coupon lengths (since v3.3.0)
<?php
add_filter( 'automatewoo/coupon_generator/key_length', 'my_filter_automatewoo_coupon_length', 10, 2 );
/**
* @param int $length
* @param AutomateWoo\Coupon_Generator $generator
* @return int
*/
function my_filter_automatewoo_coupon_length( $length, $generator ) {
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:21
AutomateWoo - Change workflow generated coupon lengths
<?php
// The length doesn't include the specified coupon prefix
add_filter( 'automatewoo/coupon_generator/key_length', function() {
return 8;
});
@danielbitzer
danielbitzer / custom-social-integration.php
Created September 21, 2017 16:36
AutomateWoo Refer A Friend - Custom Social Integration
<?php
/**
* Class VK_Referrals_Social_Integration
*/
class VK_Referrals_Social_Integration extends AutomateWoo\Referrals\Social_Integration {
/** @var string */
protected $button_class = 'btn-vk';
@danielbitzer
danielbitzer / functions.php
Created September 5, 2017 10:44
Refer A Friend - Exclude sale items from referral discounts
<?php
add_filter('automatewoo/referrals/coupon_data', 'my_automatewoo_referrals_coupon_data' );
/**
* @param array $coupon_data
* @return array
*/
function my_automatewoo_referrals_coupon_data( $coupon_data ) {
$coupon_data['exclude_sale_items'] = true;
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:23
AutomateWoo - Using shop.products custom filter option
<?php
/**
* Use variable {{ shop.products | type: 'custom', filter: 'my_shop_products_custom_filter' }}
*/
add_filter( 'my_shop_products_custom_filter', 'my_shop_products_custom_filter', 10, 2 );
/**
* @param $product_ids array
* @param $workflow AutomateWoo\Workflow
* @return array