This file contains hidden or 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
| /** | |
| * Add this code to your theme's functions.php file | |
| * or use a code snippets plugin | |
| * | |
| * This fixes the currency symbol positioning for WooCommerce on RTL sites | |
| */ | |
| // Fix WooCommerce currency position for RTL sites | |
| add_filter( 'woocommerce_price_format', function( $format, $currency_pos ) { | |
| // Only apply to RTL sites with ILS currency |
This file contains hidden or 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
| /** | |
| * Fix for Product Add-ons bypassing Sold individually setting | |
| * Add this to the theme's functions.php or as a custom plugin | |
| */ | |
| add_filter( 'woocommerce_add_to_cart_validation', 'enforce_sold_individually_with_addons', 999, 5 ); | |
| function enforce_sold_individually_with_addons( $passed, $product_id, $quantity, $variation_id = 0, $variations = array() ) { | |
| // Get the product | |
| $product = wc_get_product( $variation_id ? $variation_id : $product_id ); | |
This file contains hidden or 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
| /** | |
| * Reset variation selections after successful add to cart | |
| */ | |
| add_action( 'wp_footer', function() { | |
| if ( ! is_product() ) { | |
| return; | |
| } | |
| ?> | |
| <script type="text/javascript"> | |
| jQuery(document).ready(function($) { |
This file contains hidden or 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
| add_filter('woocommerce_product_add_to_cart_text', function($text, $product) { | |
| if ($product->get_type() === 'booking') { | |
| return __('Add to Cart', 'woocommerce'); | |
| } | |
| return $text; | |
| }, 10, 2); |
This file contains hidden or 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
| /** | |
| * Hide zero-priced downloadable products from subscription line items. | |
| */ | |
| function wcsd_hide_zero_priced_downloads() { | |
| // Filter the line items display only, not affecting the actual data. | |
| add_filter( 'woocommerce_order_get_items', 'wcsd_filter_subscription_items', 10, 3 ); | |
| // IMPORTANT: We're NOT removing the original download_permissions action | |
| // so download permissions are still properly granted. | |
| } |
This file contains hidden or 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
| // Display Global ID in regular order view | |
| add_action( 'woocommerce_after_order_itemmeta', function( $item_id, $item, $order ) { | |
| if ( is_admin() && $item->is_type( 'line_item' ) ) { | |
| $product = $item->get_product(); | |
| if ( $product && method_exists( $product, 'get_global_unique_id' ) ) { | |
| $unique_id = $product->get_global_unique_id(); | |
| if ( $unique_id ) { | |
| echo '<div class="woocommerce-item-meta" style="color: #888; font-size: 12px;"><strong>Global ID:</strong> ' . esc_html( $unique_id ) . '</div>'; | |
| } | |
| } |
This file contains hidden or 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
| /** | |
| * Simple one-time fix for WooCommerce Subscription tax calculation. | |
| * | |
| * This function automatically recalculates taxes for subscriptions when viewing them in admin. | |
| * Add this code to your theme's functions.php or a custom plugin, visit each affected | |
| * subscription once, then remove the code. | |
| * | |
| * @since 1.0.0 | |
| */ | |
| function hafwpv_fix_subscription_taxes() { |
This file contains hidden or 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
| /** | |
| * Prevent WooCommerce from auto-completing orders with $0 product total but shipping costs. | |
| * | |
| * @param bool $is_virtual Whether the order contains only virtual products. | |
| * @param WC_Order $order The order object. | |
| * @return bool | |
| */ | |
| function a8c_prevent_zero_value_order_completion( $is_virtual, $order ) { | |
| // Only modify behavior for subscription renewal orders | |
| if ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order ) ) { |
This file contains hidden or 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
| /** | |
| * Ensure resubscriptions use current product prices | |
| * Add this to your theme's functions.php or a custom functionality plugin | |
| */ | |
| add_filter( 'woocommerce_add_cart_item', 'update_resubscribe_price', 20, 1 ); | |
| add_filter( 'woocommerce_before_calculate_totals', 'update_cart_resubscribe_prices', 20, 1 ); | |
| /** | |
| * Update price when a resubscribed product is added to the cart | |
| * |
This file contains hidden or 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
| /** | |
| * Prevent resubscription to out-of-stock physical products. | |
| * Add this to your theme's functions.php or a custom functionality plugin. | |
| * | |
| * @param bool $can_resubscribe Whether the user can resubscribe to the subscription. | |
| * @param WC_Subscription $subscription The subscription object. | |
| * @param int $user_id The user ID. | |
| * @return bool Whether the user can resubscribe after stock check. | |
| */ | |
| function custom_wcs_resubscribe_stock_check( $can_resubscribe, $subscription, $user_id ) { |
NewerOlder