Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Filter global role-based discounts
*/
function prefix_role_pricing_rules( $rules, $product=false ) {
if( ! $product ) {
return $rules;
}
<?php
/**
* Get all bookings with an end date in a specified number of days time
*/
function prefix_get_bookings_ending() {
// How many days in advance should we send the email?
$days = 3;
$date = date( 'Y-m-d', strtotime( '+' . absint( $days ) . 'days' ) );
error_log( $date );
<?php
/**
* Rename product data tabs
*/
function woo_rename_tabs( $tabs ) {
$tabs['additional_information']['title'] = __( 'Product Data' );
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
<?php
/**
* Remove product data tabs
*/
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] );
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
.pewc-field-104 {
display: none;
}
<?php
/**
* Display the 'Force minimum price' setting
* This setting will be deprecated in a future version
* Please use https://pluginrepublic.com/wordpress-plugins/woocommerce-minimum-maximum-quantity-and-order/ instead
*/
add_filter( 'pewc_enable_minimum_price_option', '__return_true' );
<?php
/**
* Apply fixed discounts in Bookings for WooCommerce
*/
function prefix_discount_type( $type, $product_id ) {
return 'fixed';
}
add_filter( 'bfwc_discount_type', 'prefix_discount_type', 10, 2 );
<?php
/**
* Filter bulk discount rules by taxonomy instead of product category
*/
function prefix_validate_bulk_rule_taxonomy( $tax, $rule, $rule_id ) {
$tax = 'product_brand';
return $tax;
}
<?php
/**
* Filter exact children validation notice
*/
function prefix_exact_children_validation_notice( $notice, $label, $min_products ) {
$notice = sprintf(
__( '%s requires you to choose %s products', 'pewc' ),
esc_html( $label ),
$min_products
<?php
/**
* Populate products field using SKUs from ACF field
* Create an ACF field with the name child_product_skus
* Enter the SKUs of the child products into this field as a comma-separated list
*/
function prefix_populate_products_through_ACF( $item, $group, $group_id, $post_id ) {
// Check ACF is active
if( ! function_exists( 'get_field' ) ) {