Skip to content

Instantly share code, notes, and snippets.

View PluginRepublicSupport's full-sized avatar

PluginRepublicSupport

View GitHub Profile
@PluginRepublicSupport
PluginRepublicSupport / pewc_sum_child_product_price_cart.php
Created May 16, 2025 11:01
Display the parent product price as a sum all child products in cart
<?php
add_action( 'wp_footer', function() {
?>
<script>
jQuery(document).ready(function($) {
function updateParentPrices() {
$('.cart .pewc-parent-product').each(function() {
var $parentRow = $(this);
var groupClass = $parentRow.attr('class').split(' ').find(c => c.startsWith('pewc_'));
@PluginRepublicSupport
PluginRepublicSupport / wcvs_use_product_variation_image
Created March 4, 2025 08:04
Force use variation image on the product level for products with single attributes, when Consolidate variations setting is disabled. Requires WooCommerce Variation Swatches 1.1.6+
add_filter( 'wcvs_use_product_variation_image', function( $use, $product ){
if ( $product->is_type( 'variable' ) && 1 === count( $product->get_variation_attributes() ) ) {
$use = true;
}
return $use;
}, 10, 2 );
@PluginRepublicSupport
PluginRepublicSupport / wcmmqo_cart_quantity_blocks.php
Last active February 27, 2025 06:09
Min Max Quantity Order compatibility with WooCommerce Blocks. This should be included in 1.3.8+
<?php
/**
* Filter for the minimum quantity when the cart is using WC Blocks
* @since 1.3.8
*/
function custom_api_product_quantity_minimum( $quantity, $product, $cart_item ) {
$min = wcmmqo_get_min_quantity( $product );
if ( ! empty( $min ) ) {
$quantity = $min;
}
@PluginRepublicSupport
PluginRepublicSupport / wfad_sum_all_fees_cart.php
Created January 10, 2025 13:43
Sum/Consolidate all Fees from Dynamic Pricing
<?php
add_action( 'wp_footer', function() {
?>
<script>
jQuery(document).ready(function($) {
// Initialize the packing fee sum
let packingFeeTotal = 0;
@PluginRepublicSupport
PluginRepublicSupport / plus_minus_icons_child_products.php
Created December 10, 2024 13:59
Adding a "+" or "-" Button for Linked Child Products
<?php
add_action( "wp_footer", function() {
?>
<script>
jQuery(document).ready(function($) {
$('.pewc-child-quantity-field').before('<button type="button" class="minus">-</button>');
$('.pewc-child-quantity-field').after('<button type="button" class="plus">+</button>');
@PluginRepublicSupport
PluginRepublicSupport / pewc_custom_safari_comma_fix.php
Created November 6, 2024 15:20
Accept commas is Safari number field
<?php
function custom_safari_comma_fix() {
?>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', () => {
// Detect if the browser is Safari
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (isSafari) {
@PluginRepublicSupport
PluginRepublicSupport / bfwc_date_formatter_pattern.php
Last active November 4, 2024 06:46
Fix for fatal error in Bookings for WooCommerce because of date format
<?php
/**
* Some languages (e.g. Finnish/Suomi) encounter the error below when adding a Booking product to the cart:
* "PHP Fatal error: Uncaught DateMalformedStringException: Failed to parse time string (marraskuu 08, 2024) at position 0 (m): The timezone could not be found in the database"
* Use the snippet below to fix the error (requires 2.0.14+)
*/
add_filter( 'bfwc_date_formatter_pattern', function( $pattern ){
return 'LLLL';
}, 10, 1 );
@PluginRepublicSupport
PluginRepublicSupport / wcmo_redirect_referring_page.php
Created October 23, 2024 07:32
Filter wcmo_redirect_referring_page, for compatibility with Filter Everything PRO
<?php
/**
* Filter wcmo_redirect_referring_page, for compatibility with Filter Everything PRO
* Requires WooCommerce Members Only 1.10.19+
*/
add_filter( 'wcmo_redirect_referring_page', function( $referring_page ){
$parts = parse_url( home_url() );
$current_uri = "{$parts['scheme']}://{$parts['host']}" . ( ! empty( $parts['port'] ) ? ':' . $parts['port'] : '' ) . add_query_arg( NULL, NULL );
$referring_page = $current_uri;
@PluginRepublicSupport
PluginRepublicSupport / wp_add_role_body_class.php
Created October 17, 2024 13:26
Add the user role to the body class
<?php
function add_user_role_to_body_class($classes) {
// Check if the user is logged in
if (is_user_logged_in()) {
// Get the current user's data
$user = wp_get_current_user();
// Check if the user has any roles
if (!empty($user->roles) && is_array($user->roles)) {
// Append each role to the body class
@PluginRepublicSupport
PluginRepublicSupport / wcraq_get_total_price_quote.php
Created October 14, 2024 16:48
Request a Quote : Total price for quote table
<?php
add_action( 'wp_footer', function() {
?>
<script>
jQuery(document).ready(function($) {
function updateTotalPrice() {
var total = 0;