Skip to content

Instantly share code, notes, and snippets.

View prefix_change_condition_field_id.php
<?php
/**
* Use this snippet to make a product level field conditional on the value of a global field
* On your product level field add a condition based on another product level field
* Then enter the field and groups IDs below to swap the product level field with a global level field
*/
function prefix_get_field_ids_to_replace() {
// You need to update the field and group IDs below
$ids['global-group'] = 8812; // This is the ID of the global group
$ids['global-field'] = 8813; // This is the ID of the global field
View prefix_add_link_to_child_product_name.php
@plugin-republic
plugin-republic / pewc-upload-thumb-wrapper.css
Last active Jul 15, 2021
Hide uploaded images in cart and checkout
View pewc-upload-thumb-wrapper.css
.mini_cart_item dl img,
.cart_item dl img,
.pewc-upload-thumb-wrapper,
.mini_cart_item dl br,
.cart_item dl br,
.pewc-upload-thumb-wrapper br {
display: none
}
View wcfad_return_price_without_range.php
<?php
/**
* Prevent users outside roles with discounts seeing the discounted price
*/
add_filter( 'wcfad_return_price_without_range', '__return_true' );
View prefix_display_link_to_account_page.php
View prefix_bulk_adjusted_items.php
<?php
/**
* Ignore discount on first x items in bulk rule
*/
function prefix_bulk_adjusted_items( $quantity, $cart_item ) {
$ignore = 1; // Update the value here to equal the number of items that will not get discounted
return $quantity - $ignore;
}
add_filter( 'wcfad_bulk_adjusted_items', 'prefix_bulk_adjusted_items', 10, 2 );
View prefix_woocommerce_check_cart_items.php
<?php
/**
* Check if there are any out of stock child products in the cart
* Remove the parent product if so
*/
function prefix_woocommerce_check_cart_items() {
// If we've enabled the check
foreach( WC()->cart->cart_contents as $cart_item_key=>$cart_item ) {
View prefix_set_max_image_width_emails.php
<?php
/**
* Set max image width in order emails
*/
function prefix_set_max_image_width_emails( $css, $email ) {
$css .= '
img { max-width: 150px }
';
return $css;
}
View prefix_ptuwc_query_product_type.php
<?php
/**
* Add different product types
*/
function prefix_ptuwc_query_product_type( $tax_query, $args, $table ) {
$product_types = array( 'grouped' ); // Add your custom post types here as a comma separated list
if( $tax_query ) {
foreach( $tax_query as $index=>$arg ) {
if( isset( $arg['taxonomy'] ) && $arg['taxonomy'] == 'product_type' ) {
// Check the taxonomy given
View apaou_after_text_preview_field.php
<?php
/**
* Go to a specific slide in the product gallery when the text preview field is active
*/
function prefix_go_to_slide() {
?>
<script>
jQuery( document ).ready( function( $ ) {
$( '.pewc-advanced-preview-field' ).on( 'focus', function() {
$('.woocommerce-product-gallery').flexslider(2);