Skip to content

Instantly share code, notes, and snippets.

<?php
function demo_do_get_first_select_field_id() {
return 1163; // This is the ID of the first field, e.g. 'Manufacturer'
}
function demo_do_get_second_select_field_id() {
return 1164; // This is the ID of the second field, e.g. 'Model'
}
function demo_do_get_table_name() {
return 'models'; // This is the name of the look up table in your CSV file, e.g. 'models'
}
<?php
/**
* This is the ID of the select field that will set the min/max values
*/
function demo_minmax_get_colour_field_id() {
return 1158; // Change this ID number
}
/**
* This is the ID of the number field that has dynamic min and max values
<?php
/**
* Filter the child product label
*/
function demo_option_name( $label, $item, $product, $field_price) {
// Modify the label here
return $label;
}
add_filter( 'pewc_option_name', 'demo_option_name', 10, 4 );
<?php
/**
* Remove quantity field from all single product pages
*/
function pr_is_sold_individually_all_products( $individually, $product ) {
return $individually;
}
add_filter( 'woocommerce_is_sold_individually', 'pr_is_sold_individually_all_products', 10, 2 );
<?php
/**
* Remove quantity field from single product pages for specific products
* Update list of product IDs
*/
function pr_is_sold_individually_product_list( $individually, $product ) {
if( in_array( $product->getid(), array( 1234, 5678 ) ) ) { // Update the IDs in this list
$individually = true;
}
return $individually;
.wcbvp-grid-enabled .product-info.col-fit {
width: 50%;
max-width: 50%;
flex-basis: 50%;
overflow: hidden;
}
<?php
/**
* Set the order of attributes in the Better Variations grid
*/
function demo_swap_attributes_order( $order, $product_id ) {
return array( 'pa_colour', 'pa_size' );
}
add_filter( 'wcbvp_attribute_order', 'demo_swap_attributes_order', 10, 2 );
.pewc-checkbox-group-wrapper {
display: grid;
grid-gap: 0 10px;
grid-template-columns: 1fr 1fr;
}
<?php
/**
* Redirect users after registration
*/
function demo_registration_redirect( $redirect_url ) {
$redirect_url = '/shop'; // Redirect to shop
return $redirect_url;
}
add_filter( 'woocommerce_registration_redirect', 'demo_registration_redirect' );
<?php
/**
* Remove attributes from product names of variation child products
*/
function demo_filter_child_product_title( $title, $child_product ) {
if( ! is_object( $child_product ) || is_wp_error( $child_product ) ) {
return $title;
}
if( $child_product->get_type() == 'variation' ) {
$parent_id = $child_product->get_parent_id();