Redirect Desktop URLs on Mobile

// This snippet ONLY runs on MOBILE devices. // It checks if the user is on a desktop page and sends them to the mobile version. add_action( ‘template_redirect’, function() { // — Define your page pairs — // ‘desktop_page_slug’ =>…Continue reading

Global – Webwinkelkeur

// ACF Options page add_action(‘acf/init’, function() { if ( function_exists(‘acf_add_options_page’) ) { acf_add_options_page(array( ‘page_title’ => ‘Winkelinstellingen’, ‘menu_title’ => ‘Winkelinstellingen’, ‘menu_slug’ => ‘instellingen’, ‘capability’ => ‘edit_posts’, ‘redirect’ => true, )); } }); // ACF read only fields function wwk_acf_read_only_field( $field )…Continue reading

Single product – Custom stock melding

// Verberg availability/stock tekst voor variaties met ‘Toestaan, maar klant informeren’ add_filter( ‘woocommerce_get_availability_text’, function( $availability, $product ) { if ( $product && $product->is_type(‘variation’) ) { // toon geen availability tekst als backorders toegestaan zijn mét notificatie en het item op…Continue reading

Single product – Exclude attributes van tab

function mycode_hide_attributes_from_additional_info_tabs( $attributes, $product ) { /** * Array of attributes to hide from the Additional Information * tab on single WooCommerce product pages. */ $hidden_attributes = [ ‘pa_kleur’, ‘pa_maat’, ‘pa_lengtemaat’, ‘pa_filter-color’, ‘pa_taillemaat’, ‘pa_merk’ ]; foreach ( $hidden_attributes as $hidden_attribute…Continue reading

Global – Winkelmededeling

add_action( ‘wp_body_open’, ‘toon_winkelmededeling_banner’ ); function toon_winkelmededeling_banner() { $tekst = get_field( ‘winkelmededeling_tekst’, ‘option’ ); $link = get_field( ‘winkelmededeling_link’, ‘option’ ); $start_datum = get_field( ‘winkelmededeling_start’, ‘option’ ); $start_tijd = get_field( ‘winkelmededeling_starttijd’, ‘option’ ); $eind_datum = get_field( ‘winkelmededeling_einde’, ‘option’ ); $eind_tijd = get_field(…Continue reading

Gravity Forms – product list

// ============================================================================ // Gravity Forms: vul keuzelijst met producten en selecteer huidig product // Filters: gform_pre_render/admin_pre_render/pre_validation/pre_submission_filter // ============================================================================ add_filter( ‘gform_pre_render’, ‘populate_product_select_with_selected’ ); add_filter( ‘gform_admin_pre_render’, ‘populate_product_select_with_selected’ ); add_filter( ‘gform_pre_validation’, ‘populate_product_select_with_selected’ ); add_filter( ‘gform_pre_submission_filter’, ‘populate_product_select_with_selected’ ); function populate_product_select_with_selected( $form ) { if(…Continue reading

Single product – Sort attributes kleur first

add_filter( ‘woocommerce_product_get_attributes’, function( $attributes, $product ) { // Mogelijke kleur-attribuutnamen $color_keys = [ ‘pa_kleur’, ‘pa_color’ ]; // Zoek welke aanwezig is $found_key = null; foreach ( $color_keys as $key ) { if ( isset( $attributes[ $key ] ) ) {…Continue reading

Global – Change sale to % sale

// Bereken kortingspercentages function my_get_discount_percentages( $product ) { $percentages = []; if ( $product->is_type( ‘variable’ ) ) { $prices = $product->get_variation_prices( true ); foreach ( $prices[‘regular_price’] as $key_id => $regular_price ) { $sale_price = $prices[‘price’][ $key_id ]; if ( $regular_price…Continue reading

Product category – Shortcode for category image

/** * Shortcode: toon de thumbnail van de huidige WooCommerce productcategorie * * Gebruik: [category_thumbnail] */ function woocommerce_category_image_shortcode() { // Alleen uitvoeren op categorie-archieven if ( ! is_product_category() ) { return ”; // niets tonen buiten categoriepagina } global $wp_query;…Continue reading