2023

Adomatiq

2023

AGVE

2024

Aluflex

Extra plugin: Real Media Library, WP Sheet Editor, SolidComponents

/* Display custom meta data in order email, after the order table */
add_action('woocommerce_email_before_order_table', 'lw_add_item_meta_to_email', 10, 4);
function lw_add_item_meta_to_email($order, $sent_to_admin, $plain_text, $email) {
	$items = $order->get_items();
	echo '<div style="padding: 10px;">';
	echo '<h2>' . __("Order summary", "seodr") . '</h2>';
	echo '<div style="padding-bottom: 4px;"><strong>' . __("Product", "seodr") . ' <div style="float: right;">' . __("Quantity", "seodr") . '</strong></div></div>';
	foreach ($items as $item) {
		$meta_data = $item->get_meta_data();
		$sku = get_post_meta($item->get_product_id(), '_sku', true); //viktigt att ange metafältsnamn med understreck framför, funkar med acf-fält med

		echo '<div style="margin-top: 12px;">' . $item->get_name() . '<div style="float: right;">' . $item->get_quantity() . '</div></div>';
		// get the item sku

		if (empty($meta_data)) {
			echo '<div>' . __("Art. no: ", "seodr") . '<strong>' . $sku . '</strong></div>';
		}

		foreach ($meta_data as $meta) {
			if ($meta->key == 'Art. no') {
			echo '<div>' . __("Art. no: ", "seodr") . '<strong>' . $meta->value . '</strong></div>';
		}
	}
}
echo '</div>';
}
/* ACF Field-setting: Array */
<?php $img = get_field('bild_acf');?> 

/* ACF Field Group-setting: Attachment > All image formats. Field inuti Field Group är en checkbox. */
<?php $acf_field = get_field('ljusellermork', $img['ID']);?>

/* HTML */
<div id="preline" class="<?php if($acf_field==true):?>dark<?php else:?>light<?php endif;?>"></div>
/* Göm/visa submenu vid klick på menu parent */
$(".nav .menu-item-has-children").click(function () {
	$(this).toggleClass("active");
	$(this).siblings().removeClass("active");
});	 
/* Göm submenu vid klick utanför menu parent/submenu */
$(document).mouseup(function (e) {
	if ($(e.target).closest(".nav .menu-item-has-children.active").length === 0) {
		$(".nav .menu-item-has-children.active").removeClass("active");
	}
});
/* (CSS; .menu-item-has-children.active .sub-menu{display:block} ) */
2021

Assalub

2020

Badrumsspecialisten

// Display custom cart item meta data (in cart and checkout)
add_filter( 'woocommerce_cart_item_name', 'customizing_cart_item_name', 10, 3 );
function customizing_cart_item_name( $product_name, $cart_item, $cart_item_key ) {
    $product = $cart_item['data']; // Get the WC_Product Object
    $product_instance = wc_get_product($product->get_id());
    $product_full_description = strip_tags($product_instance->get_description());
    $product_short_description = $product_instance->get_short_description();
    $desc_string = explode(' ', $product_full_description); // Split the string into an array of words
    if (count($desc_string) > '30') {
        $description_txt = implode(' ', array_slice($desc_string, 0, '30')) . '...';
    } else {
        $description_txt = $product_full_description;
    }
    if ( $value = $description_txt ) {
        $product_name .= '<small class="cart-desc">'. strip_tags($value).'</small>';
    }
    return $product_name;
}
add_filter( 'woocommerce_order_item_name', 'filter_order_item_name_callback', 10, 3 );
function filter_order_item_name_callback( $item_name, $item, $is_visible ) {
    if( ! is_wc_endpoint_url() > 0 ) {
        $product = $item->get_product();
        // For product variation type
        if( $item->get_variation_id() > 0 ){
            $parent_product = wc_get_product( $item->get_product_id() );
            $product_permalink = $parent_product->get_permalink();
        } 
        // For variable products
        else {
            $product_permalink = $product->get_permalink();
        }
        return sprintf( '<a href="%s">%s</a>', $product_permalink, $item_name );
    }
    return $item_name;
}
/* Change price 0 to Offert in Cart */
function change_product_price_cart( $price, $cart_item, $cart_item_key ) {
    $product_id=$cart_item['product_id'];
    $cartproduct=wc_get_product( $product_id );
    if ($cartproduct->is_type('variable')) {
        $theprice = $cartproduct->get_variation_price();
        if (($theprice == '0')) {
            $price= __("Offert","html5_blank");
        }
    } elseif ($cartproduct->is_type('simple')) {
        $theprice = $cartproduct->get_price();
        if (($theprice == '0')) {
            $price= __("Offert","html5_blank");
        }
    }
    return $price;
}
add_filter( 'woocommerce_cart_item_price', 'change_product_price_cart', 10, 3 );
add_filter( 'woocommerce_cart_item_subtotal','change_product_price_cart', 10, 3 );
2020

Bejoken

2020

Besab

2023

Bifab

Extra plugin: Real Media Library