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_package_rates', 'wpsites_show_only_free_shipping_for_specific_product', 20, 2 ); | |
| function wpsites_show_only_free_shipping_for_specific_product( $rates, $package ) { | |
| $target_product_id = 6455; // 🔹 Replace with your product ID | |
| $product_in_cart = false; | |
| // Check if the target product is in the cart | |
| foreach ( $package['contents'] as $item ) { | |
| if ( $item['product_id'] == $target_product_id ) { | |
| $product_in_cart = true; | |
| break; |
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_action( 'woocommerce_single_product_summary', 'display_all_brand_thumbnails_on_product_page', 25 ); | |
| function display_all_brand_thumbnails_on_product_page() { | |
| global $post; | |
| $brands = wp_get_post_terms( $post->ID, 'product_brand' ); | |
| if ( ! empty( $brands ) && ! is_wp_error( $brands ) ) { | |
| // Output container for brand logos | |
| echo '<div class="product-brand-thumbnails">'; |
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_action( 'woocommerce_single_product_summary', function() { | |
| global $product; | |
| $gtin = get_post_meta( $product->get_id(), '_global_unique_id', true ); | |
| if ( $gtin ) { | |
| echo '<p class="product-gtin">GTIN: ' . esc_html( $gtin ) . '</p>'; | |
| } | |
| }, 25 ); |
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
| function enqueue_modal_popup_script_on_checkout() { | |
| if (is_checkout()) { | |
| // Enqueue jQuery (if it's not already loaded) | |
| wp_enqueue_script('jquery'); | |
| ?> | |
| <style type="text/css"> | |
| /* Modal Styling */ | |
| .modal { | |
| display: none; /* Hidden by default */ |
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 custom HTML to the WooCommerce thank you page | |
| add_action('woocommerce_thankyou', 'custom_html_confirmation_page_1001'); | |
| function custom_html_confirmation_page_1001($order_id) { | |
| $order = wc_get_order($order_id); | |
| echo '<div class="custom-confirmation-message">'; | |
| echo '<h2>Thank you for your purchase!</h2>'; | |
| echo '<p>Your order number is: ' . $order->get_order_number() . '</p>'; | |
| echo '<p>We appreciate your business and will send you a confirmation email shortly.</p>'; | |
| echo '</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
| // Version 1.0 | |
| function add_tiktok_pixel() { | |
| ?> | |
| <!-- TikTok Pixel Code --> | |
| <script> | |
| !function (w, d, t) { | |
| w.TiktokAnalyticsObject = t; | |
| var ttq = w[t] = w[t] || []; | |
| ttq.methods = ["page", "track", "identify", "instances", "debug", "on", "off", "once", "ready", "alias", "group", "enableCookie", "disableCookie"]; | |
| ttq.setAndDefer = function (t, e) { |
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_package_rates', 'wpsites_remove_flat_rate_methods_over_150', 10, 2); | |
| function wpsites_remove_flat_rate_methods_over_150($rates, $package) { | |
| $cart_total = WC()->cart->get_cart_contents_total(); | |
| $threshold = 150; | |
| // Define the shipping method IDs to remove if cart total exceeds $150 | |
| $methods_to_remove = array( | |
| 'flat_rate:12', |
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_package_rates', 'switch_flat_rate_based_on_total_v3', 10, 2); | |
| function switch_flat_rate_based_on_total_v3($rates, $package) { | |
| $cart_total = WC()->cart->get_cart_contents_total(); | |
| $flat_rate_5 = 'flat_rate:5'; // ID for flat rate 5 | |
| $flat_rate_7 = 'flat_rate:7'; // ID for flat rate 7 | |
| if ($cart_total > 150) { | |
| if (isset($rates[$flat_rate_5])) { | |
| unset($rates[$flat_rate_5]); |
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_action('woocommerce_product_options_general_product_data', 'add_custom_fields'); | |
| function add_custom_fields() { | |
| woocommerce_wp_text_input( array( | |
| 'id' => '_shipping_detail', | |
| 'label' => 'Shipping Detail', | |
| 'desc_tip' => 'true', | |
| 'description' => 'Enter the shipping details.', | |
| )); | |
| woocommerce_wp_text_input( array( |
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_action( 'woocommerce_before_add_to_cart_button', 'custom_product_addons', 10 ); | |
| function custom_product_addons() { | |
| global $product; | |
| $product_price = $product->get_price(); // Base price of the product. | |
| ?> | |
| <div id="product-warranty-addons"> | |
| <p>Select Additional Warranty:</p> | |
| <button type="button" class="warranty-addon" data-addon="15" data-price="<?php echo esc_attr( $product_price ); ?>"> | |
| Additional 4-Month Warranty (+15%) | |
| </button> |
NewerOlder