Skip to content

Instantly share code, notes, and snippets.

View PluginRepublicSupport's full-sized avatar

PluginRepublicSupport

View GitHub Profile
@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;
@PluginRepublicSupport
PluginRepublicSupport / pewc_hide_unpublished_global_groups.php
Created October 3, 2024 07:54
Hide unpublished Global Groups on the frontend for non-admins
<?php
/**
* Hide unpublished Global Groups on the frontend for non-admins
*/
add_filter( 'pewc_filter_product_extra_groups', 'custom_filter_groups_hide_unpublished', 10, 2 );
function custom_filter_groups_hide_unpublished( $product_extra_groups, $product_id ) {
if ( ! empty( $product_extra_groups ) && is_product() ) {
// only filter when on the product page
foreach ( $product_extra_groups as $global_id => $group ) {
if ( 'publish' !== get_post_status( $global_id ) && ! current_user_can( 'administrator' ) ) {
@PluginRepublicSupport
PluginRepublicSupport / pewc_swatch_layer_url_to_absolute_path.php
Last active August 20, 2024 08:35
Use this snippet if Imagick has issues opening URLs
<?php
/**
* Converts full URL of images to absolute path. Requires Product Add-Ons Ultimate 3.21.4
*/
add_filter( 'pewc_swatch_layer_base_image_url', 'pewc_url_to_absolute_path', 10, 1 );
add_filter( 'pewc_swatch_layer_swatch_url', 'pewc_url_to_absolute_path', 10, 1 );
function pewc_url_to_absolute_path( $url ) {
$path = str_replace( site_url(), $_SERVER['DOCUMENT_ROOT'], $url );
return $path;
}
@PluginRepublicSupport
PluginRepublicSupport / pewc_swatch_layer_composite_constant.php
Last active August 19, 2024 07:25
Use this filter if the layered image appears black
<?php
/**
* Use this filter if the layered image appears black. Requires Product Add-Ons Ultimate 3.21.4
*/
add_filter( 'pewc_swatch_layer_composite_constant', function( $constant ){
return Imagick::COMPOSITE_DEFAULT;
}, 10, 1 );