Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Don't apply discount to add-on fields
*/
add_filter( 'pewc_disable_wcfad_on_addons', '__return_true' );
// Always display the quantity field
add_filter( 'pewc_hide_quantity', '__return_false' );
<?php
/**
* Add a CSS class to products on archive pages if they have add-on fields.
*/
function demo_add_has_addons_class( $classes ) {
if ( is_archive() || is_shop() ) {
global $product;
if ( $product && 'yes' === pewc_has_product_extra_groups( $product->get_id() ) ) {
$classes[] = 'pewc-has-addons';
}
<?php
/**
* Ensure user can't order more parent products than child product stock allows
* Only applies to child product with 'Linked' quantities
*/
<?php
/**
* Ensure user can't order more parent products than child product stock allows
* Only applies to child product with 'Linked' quantities
*/
<?php
/**
* Update variation taxonomies after WP All Import import completes
*/
function demo_after_xml_import( $import_id, $import ) {
if( function_exists( 'wcbvp_update_all_variations' ) ) {
wcbvp_update_all_variations();
}
}
add_action( 'pmxi_after_xml_import', 'demo_after_xml_import', 10, 2 );
<?php
/**
* Change variation image in Products field Column layout
*/
add_filter( 'pewc_column_layout_replace_thumbnail', '__return_true' );
<?php
/**
* Snippet: Auto-delete PEWC uploaded files 30 days after an order is completed.
*
* When an order transitions to "completed", a one-time WP-Cron event is scheduled
* for 30 days later. When that event fires, any uploaded files attached to the
* order are deleted from the filesystem and the order is marked accordingly.
*
* Usage: add this file as an mu-plugin, or require it from your theme/child-theme
* functions.php, or use a snippet plugin such as Code Snippets.
<?php
/* This code was provided by WebToffee support on 10/21/25
* Makes Plugin Republic's Product Add-ons plugin available to use in the packing list PDF
*/
add_filter( 'wf_pklist_add_package_product_meta', 'wf_pklist_add_additional_fields', 10, 5 );
function wf_pklist_add_additional_fields( $additional_product_meta, $template_type, $_product, $order_item, $order ) {
if ( 'packinglist' !== $template_type ) {
return $additional_product_meta;
}
<?php
/**
* Send test email for DPP
* Replace $order_id with an existing scheduled order on your site
* Refresh a WooCommerce page, e.g. WooCommerce > Orders to fire the snippet
*/
function prefix_test_scheduled_order_due_email() {
$order_id = 91;
wcdpp_scheduled_order_due_email( $order_id );
}