Type: php
Untitled Snippet
WWPP – Customize the admin “New Order” email subject for wholesalers v1.1
/** * Customize the Admin “New Order” email subject using Wholesale Prices Premium logic */ add_filter( ‘woocommerce_email_subject_new_order’, function( $subject, $order ) { if ( ! $order ) { return $subject; } // Access the Wholesale Prices Premium global object global…Continue reading
WWPP – Customize the admin “New Order” email subject for wholesalers
/** * Customize the Admin “New Order” email subject for wholesale customers only */ add_filter( ‘woocommerce_email_subject_new_order’, function( $subject, $order ) { if ( ! $order ) { return $subject; } $customer_id = $order->get_customer_id(); if ( ! $customer_id ) { return…Continue reading
Social Share Buttons (copy)
$post_url = urlencode( get_permalink() ); $post_title = urlencode( get_the_title() ); $facebook_url = “https://www.facebook.com/sharer/sharer.php?u=$post_url”; $x_url = “https://twitter.com/intent/tweet?url=$post_url&text=$post_title”; $linkedin_url = “https://www.linkedin.com/shareArticle?mini=true&url=$post_url&title=$post_title”; $social_buttons = ‘ ‘; echo $social_buttons; // Styles for the social sharing buttons. echo ‘ ‘;Continue reading
Untitled Snippet
WWPP – Restrict add-to-cart on specific products to a specific wholesale role only
// 1. Make the product unpurchasable for non-doctors add_filter( ‘woocommerce_is_purchasable’, ‘wws_restrict_purchase_for_doctors’, 10, 2 ); function wws_restrict_purchase_for_doctors( $is_purchasable, $product ) { $allowed_role = ‘doctors’; $restricted_category = ‘doctors-only’; $product_id = $product->is_type( ‘variation’ ) ? $product->get_parent_id() : $product->get_id(); if ( has_term( $restricted_category, ‘product_cat’,…Continue reading
WWPP – Restrict add-to-cart on specific products to a specific wholesale role only
/** * Restrict add-to-cart on specific products to the ‘doctors’ wholesale role only. * * Usage: * 1. Set DOCTORS_ROLE_SLUG below to match the wholesale role slug you created in * WooCommerce > Wholesale Roles. * 2. On each product’s…Continue reading
Removal Redirect
add_action(‘template_redirect’, function () { if (is_admin()) { return; } $request_path = trim(parse_url($_SERVER[‘REQUEST_URI’], PHP_URL_PATH), ‘/’); // Match /removal-request/ on any mapped subsite domain if ($request_path === ‘removal-request’) { wp_safe_redirect(home_url(‘/privacy-policy-2/’), 301); exit; } });Continue reading
Apollo Website Tracking
function add_apollo_tracker() { ?>Continue reading