Archives: Snippets
Untitled Snippet
Apply Coupon when a radio button is clicked on The WooCommerce Product Page
/** * Snippet: Apply Coupon when a radio button is clicked on The Product Page * Author: https://profiles.wordpress.org/kishores * Url: https://upnrunn.com * Note: Please make sure to create the coupon in the WC Admin */ // Add radio button below…Continue reading
Exclude Product From Discount Coupons in WooCommerce
/** * Snippet Name: Exclude Product From Discount Coupons. */ add_filter( ‘woocommerce_coupon_is_valid_for_product’, ‘exclude_product_from_product_promotions’, 999, 4 ); function exclude_product_from_product_promotions( $valid, $product, $coupon, $values ) { // Product id here (i.e. 123) if ( 123 == $product->get_id() ) { $valid = false;…Continue reading
How to Add Diwali Celebration Animation in WordPress Website
function add_custom_div(){ echo ‘ ‘; echo ‘ ‘; echo ‘ ‘; } add_action( ‘wp_footer’, ‘add_custom_div’ ); function diwali_js() { ?>Continue reading
Apply discount on the cheapest item in WooCommerce
/** * Snippet Name: Apply discount on the cheapest item */ add_action( ‘woocommerce_before_calculate_totals’, ‘apply_discount_on_cheapest_item’, 999 ); function apply_discount_on_cheapest_item( $cart ) { if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) return; if ( did_action( ‘woocommerce_before_calculate_totals’ ) >= 2 ) return;…Continue reading
Disable a Payment Gateway for a country on WooCommerce Checkout Page
/** * Snippet: Disable a Payment Gateway for a country */ add_filter( ‘woocommerce_available_payment_gateways’, ‘disable_payment_gateway_based_on_country’, 9999 ); function disable_payment_gateway_based_on_country( $available_gateways ) { if ( is_admin() ) return $available_gateways; if ( isset( $available_gateways[‘stripe’] ) && WC()->customer && WC()->customer->get_billing_country() == ‘IN’ ) {…Continue reading
Filter Countries JUST for Donation Forms
add_filter( ‘charitable_default_donation_fields’, ‘charitable_filter_countries_donation_form’, 10, 1 ); function charitable_filter_countries_donation_form( $donation_fields = array() ) { if ( empty( $donation_fields[‘country’][‘donation_form’][‘options’] ) ) { return $donation_fields; } $countries_for_donation_form = $donation_fields[‘country’][‘donation_form’][‘options’]; // you can remove a country. unset( $countries_for_donation_form[‘CA’] ); // ..or you can create…Continue reading
Conditionally Show the Submit Button
/** * Conditionally show the submit button * * @link https://wpforms.com/developers/how-to-conditionally-show-the-submit-button/ */ add_action( ‘wp_head’, function () { ?>Continue reading
Button-Movement #The Greek
button { padding: 10px 20px; font-size: 16px; transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s; border-radius: 5px; } button:hover { background-color: #ff6347; transform: scale(1.1) rotate(3deg); box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.3); }Continue reading