Set Stripe as default gateway in checkout

add_action(‘template_redirect’, ‘define_default_payment_gateway’); function define_default_payment_gateway() { // Prevent execution during admin, AJAX, or scheduled tasks if (is_admin() || wp_doing_ajax() || wp_doing_cron()) { return; } if (is_checkout() && !is_wc_endpoint_url()) { WC()->session->set(‘chosen_payment_method’, ‘stripe’); } }Continue reading

Discounts for Trade users FE

add_action(‘woocommerce_cart_calculate_fees’, ‘apply_trade_discount_by_category’, 20, 1); function apply_trade_discount_by_category($cart) { if (is_admin() && !defined(‘DOING_AJAX’)) return; // Ensure it only runs on the front-end $user = wp_get_current_user(); // Only apply discount for users with the “trade” role if (!in_array(‘trade’, (array) $user->roles)) { return; }…Continue reading

Discounts for Sister org users FE

add_action(‘woocommerce_cart_calculate_fees’, ‘apply_sister_discount_by_category’, 20, 1); function apply_sister_discount_by_category($cart) { if (is_admin() && !defined(‘DOING_AJAX’)) return; // Ensure it only runs on the front-end $user = wp_get_current_user(); // Only apply discount for users with the “sister” role if (!in_array(‘sister’, (array) $user->roles)) { return; }…Continue reading

Discounts for Full timer users FE

add_action(‘woocommerce_cart_calculate_fees’, ‘apply_fulltimer_discount_by_category’, 20, 1); function apply_fulltimer_discount_by_category($cart) { if (is_admin() && !defined(‘DOING_AJAX’)) return; // Ensure it only runs on the front-end $user = wp_get_current_user(); // Only apply discount for users with the “fulltimer” role if (!in_array(‘fulltimer’, (array) $user->roles)) { return; }…Continue reading

Single product – SKU en Merkfoto

// Add merk logo to single product add_action(‘woocommerce_single_product_summary’, ‘toon_merk_logo_op_productpagina’, 5); function toon_merk_logo_op_productpagina() { global $product; $opening_tag = false; // Get SKU $product_number = $product->get_sku(); if ($product_number) { $opening_tag = true; // Let op: Alleen opening tag echo ‘ ‘; echo…Continue reading

Get X – Force RankMath OG Local CA

/** * Get X Media – Force RankMath Canada Targeting (Aggressive) * * @package GetXMedia_RankMath_CA * @author Get X Media * @version 2.0.0 */ if ( ! defined( ‘ABSPATH’ ) ) { exit; } /** * Replace RankMath’s en_US locale…Continue reading

Current Year

function wpcode_current_year() { return date(‘Y’); } add_shortcode(‘current_year’, ‘wpcode_current_year’);Continue reading

hkosnip

// index.php?name=david echo $_GET[‘name’]; // index.php?name=david&surname=adams echo $_GET[‘surname’];Continue reading

Untitled Snippet

/** * WPCode: Highwire meta – Revista Chilena de Anestesiología (robusto + debug) * – Imprime meta tags en de posts. * – No requiere ACF salvo para el repeater de autores (contrib). * – Incluye comentario HTML de debug…Continue reading