Skip to content

Instantly share code, notes, and snippets.

Gareth Harris plugin-republic

Block or report user

Report or block plugin-republic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pewc_filter_initial_accordion_states.php
<?php
/**
* Set all groups to closed (or open) in an accordion
*/
function prefix_filter_initial_accordion_states( $state, $post_id ) {
return 'closed'; // Comment this out and uncomment the line below to set all groups to open
// return 'open';
}
add_filter( 'pewc_filter_initial_accordion_states', 'prefix_filter_initial_accordion_states', 10, 2 );
View prefix_filter_field_option_name.php
<?php
/**
* Filter select and radio option names
*/
function prefix_filter_field_option_name( $name, $key, $item, $product ) {
$product_price = $product->get_price();
$name .= ' - Only ' . $product_price;
return $name;
}
add_filter( 'prefix_filter_field_option_name', 'prefix_filter_field_option_name', 10, 4 );
View pewc_number_field_step.php
<?php
/**
* Filter the step parameter in Number fields
*/
function prefix_number_field_step( $step, $item ) {
return 1;
}
add_filter( 'pewc_number_field_step', 'prefix_number_field_step', 10, 2 );
View pewc_hidden_group_types_in_order.php
<?php
/**
* Prevent some field types from being displayed in order data
*/
function prefix_hidden_group_types_in_order( $group_types ) {
$group_types = array( 'calculation' );
return $group_types;
}
add_filter( 'pewc_hidden_group_types_in_order', 'prefix_hidden_group_types_in_order' );
View pewc_filter_upload_files_messages.php
<?php
/**
* Change the 'Drop files here to upload' message
*/
function tester_pewc_filter_drop_files_message( $message, $post_id ) {
return 'Your message';
}
add_filter( 'pewc_filter_drop_files_message', 'tester_pewc_filter_drop_files_message', 10, 2 );
/**
View pewc_show_field_prices_in_cart.php
<?php
/**
* Hide all field prices in the cart
*/
add_filter( 'pewc_show_field_prices_in_cart', '__return_false' );
View pewc_filter_field_params.php
<?php
// Use this if you are not using calculation fields
add_filter( 'pewc_show_calculation_params', '__return_false' );
// Use this if you are not using any fields with options, e.g. radio, select
add_filter( 'pewc_show_option_field_params', '__return_false' );
// Use this if you are not using information fields
add_filter( 'pewc_show_information_params', '__return_false' );
// Use this if you are not using checkbox group fields
add_filter( 'pewc_show_checkbox_group_params', '__return_false' );
// Use this if you are not using child products fields
View pewc_filter_child_products_method.php
<?php
/**
* Filter which product type is used in the Products field
* @param $product_type
* @param $product_id Product ID - use this to conditionally change product type per product
* @param $field_id Field ID - use this to conditionally change product type per field
*/
function prefix_search_products( $product_type, $product_id, $field_id ) {
// $product_type = 'woocommerce_json_search_products_and_variations'; // Allows you to include variations
// $product_type = 'variable_subscriptions'; // Include variations for subscriptions
View description_under_label.php
<?php
/**
* Move the description under the label for product add-ons
*/
function prefix_field_description_list_layout( $item, $id, $group_layout, $file ) {
pewc_field_description( $item, $id, $group_layout );
}
add_action( 'pewc_before_include_frontend_template', 'prefix_field_description_list_layout', 10, 4 );
// Remove the description field from after the field
View pewc_option_price_separator.php
<?php
/**
* Change the separator between an option name and its additional price
*/
function prefix_pewc_option_price_separator( $sep, $item ) {
$sep = ' + ';
return $sep;
}
add_filter( 'pewc_option_price_separator', 'prefix_pewc_option_price_separator', 10, 2 );
You can’t perform that action at this time.