Skip to content

Instantly share code, notes, and snippets.

View woogists's full-sized avatar

WooGists woogists

View GitHub Profile
@woogists
woogists / wc-box-office-scan-permissions.php
Last active July 9, 2018 19:24
[Box Office] Allows you to change the scan permissions of WooCommerce Box Office
add_filter( 'woocommerce_box_office_scan_permission', 'modify_woocommerce_box_office_scan_permission' );
function modify_woocommerce_box_office_scan_permission( $has_permission ) {
// Do any required permission checks here
$has_permission = true;
return $has_permission;
}
@woogists
woogists / wc-paypal-express-remove-proceed-checkout-button.php
Last active August 24, 2019 06:04
[PayPal Express Checkout] Remove the “Proceed to Checkout” link on the cart page
/*
* Snippet to remove the 'Proceed to Checkout' link on the cart page.
* Code goes in the functions.php file in your theme.
*/
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
@woogists
woogists / wc-google-analytics-pro-tracking-events.php
Created March 9, 2018 14:59
[Google Analytics Pro] Tracking custom events
wc_google_analytics_pro()->get_integration()->custom_event( $event_name, $properties );
@woogists
woogists / wc-google-analytics-pro-tracking-events-example.php
Created March 9, 2018 15:00
[Google Analytics Pro] Tracking custom events snippet example
if ( ! function_exists( 'my_custom_event_function' ) ) {
function my_custom_event_function() {
wc_google_analytics_pro()->get_integration()->custom_event( 'Event name', array( 'Property name' => 'value' ) );
}
add_action( 'hook_to_trigger_event_on', 'custom_event_function' );
}
@woogists
woogists / wc-drip-custom-fields.php
Created March 9, 2018 15:06
[WooCommerce Drip] This filter allows you to customize the subscriber custom fields sent to Drip. This is an example of sending the first and last names instead of a general full name:
add_filter( 'wcdrip_custom_fields', 'drip_add_first_last_fields', 10, 5 );
function drip_add_first_last_fields( $filters, $email, $lifetime_value, $products, $order ) {
unset( $filters['name'] );
$filters['first_name'] = $order->billing_first_name;
$filters['last_name'] = $order->billing_last_name;
return $filters;
}
@woogists
woogists / wc-drip-subscribe-params.php
Created March 9, 2018 15:08
[WooCommerce Drip] This filter allows you to modify parameters used to subscribe a customer to a campaign during registration.
add_filter( 'wcdrip_checkout_subscribe_params', 'drip_make_optin_single' );
add_filter( 'wcdrip_register_subscribe_params', 'drip_make_optin_single' );
function drip_make_optin_single( $params ) {
$params['double_optin'] = false;
return $params;
}
@woogists
woogists / wc-pdf-watermark-adding-more-tags-watermarks.php
Created March 9, 2018 15:08
[WooCommerce PDF Watermark] Adding More Tags To Text Watermarks
/*
* Snippet to add more tags to text watermarks.
* Code goes in the functions.php file in your theme.
*/
function wc_pdf_watermark_extend_template_tags( $parsed_text, $unparsed_text, $order, $product ) {
// Look for {product_title} in text and replace it with the product title
$parsed_text = str_replace( '{product_title}', $product->get_title(), $parsed_text );
return $parsed_text;
}
add_filter( 'woocommerce_pdf_watermark_parse_template_tags', 'wc_pdf_watermark_extend_template_tags', 10, 4 );
@woogists
woogists / wc-photography-change-visibility.php
Created March 9, 2018 15:10
[WooCommerce Photography] This snippet will prevent customers from changing permissions for a collection.
add_filter( 'woocommerce_photography_customers_can_change_visibility', '__return_true' );
@woogists
woogists / wc-pdf-watermarks-change-password-pdf-downloads.php
Created March 9, 2018 15:11
[WooCommerce PDF Watermarks] Change password used for protecting PDF downloads
/*
* Snippet to change password used for protecting PDF download
* Code goes in the functions.php file in your theme.
*/
function wc_pdf_watermark_change_pdf_password( $order_id, $product_id ) {
// Use the order number for the password instead of the billing email
$order = wc_get_order( $order_id );
return $order->get_order_number();
}
@woogists
woogists / wc-ninja-forms-product-add-ons-hide-zero-price-add-ons.php
Created March 9, 2018 15:14
[WooCommerce Ninja Forms Product Add-ons] Hide price add-ons equal to zero
/*
* Snippet to hide price add-ons equal to zero.
* Code goes in the functions.php file in your theme.
*/
add_filter( 'wc_nf_addons_format_cart_item_price' , 'wc_ninja_forms_hide_zero_price' );
function wc_ninja_forms_hide_zero_price( $value ) {
$hide_price = ' (' . wc_price( '0.00' ) . ')';