This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_footer', function() { | |
?> | |
<script> | |
jQuery(document).ready(function($) { | |
// Initialize the packing fee sum | |
let packingFeeTotal = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_footer', function() { | |
?> | |
<script> | |
jQuery(document).ready(function($) { | |
function updateTotalPrice() { | |
var total = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
NewerOlder