/** * Theme functions and definitions. * * For additional information on potential customization options, * read the developers' documentation: * * https://developers.elementor.com/docs/hello-elementor-theme/ * * @package HelloElementorChild */ if (! defined('ABSPATH')) { exit; // Exit if accessed directly. } define('HELLO_ELEMENTOR_CHILD_VERSION', '2.0.0'); /** * Load child theme scripts & styles. * * @return void */ function hello_elementor_child_scripts_styles() { wp_enqueue_style( 'hello-elementor-child-style', get_stylesheet_directory_uri() . '/style.css', [ 'hello-elementor-theme-style', ], HELLO_ELEMENTOR_CHILD_VERSION ); } add_action('wp_enqueue_scripts', 'hello_elementor_child_scripts_styles', 20); // New actions to split up cart totals and cross sell on cart page add_action('hproc_woocommerce_cart_totals', 'woocommerce_cart_totals', 10); add_action('hproc_woocommerce_cart_cross_sell', 'woocommerce_cross_sell_display'); add_action('acf/init', 'set_acf_settings'); function set_acf_settings() { acf_update_setting('enable_shortcode', true); } function custom_short_description_shortcode() { global $post; $short_description = get_the_excerpt($post->ID); $max_length = 40; // Maximalt antal tecken if (strlen($short_description) > $max_length) { $short_description = substr($short_description, 0, $max_length) . '...'; } return '
' . $short_description . '
'; } add_shortcode('short_description', 'custom_short_description_shortcode'); // // Helpers // function hproc_dump($value) { echo "
";
	print_r($value);
	echo "
"; } /* Lägger till is_reseller och is_company i get order rest api svaret */ add_filter('woocommerce_rest_prepare_shop_order_object', 'hproc_wc_rest_api_extend_order_lineitems_data', 10, 3); function hproc_wc_rest_api_extend_order_lineitems_data($response, $object, $request) { if (empty($response->data)) { return $response; } /* Plockar ut order data från svaret */ $order_data = $response->get_data(); /* Hämta user objektet via ID. customer_id finns på order objektet */ $user = get_user_by("id", $order_data["customer_id"]); /* Är user objektet tomt skickar vi false */ if (empty($user)) { $order_data["is_reseller"] = false; $order_data["is_company"] = false; $order_data["user_email"] = ""; } else { /* Plocka ut alla roller från user objektet */ $roles = $user->roles; /* Om rollerna är tom skickar vi false */ if (empty($roles) || count($roles) <= 0) { $order_data["is_reseller"] = false; $order_data["is_company"] = false; } else { $isReseller = false; $isCompany = false; /* $user->roles är en array även om man bara kan sätta 1 roll. Gör en foreach om detta ändras framöver. */ foreach ($roles as $role) { /* Om rollen börjar med b2b hanterar vi denna som ÅF roll och sätter $isReseller till true */ if (substr_compare($role, "b2b", 0, 3, true) === 0) { $isReseller = true; $isCompany = true; } if ($role == "company") { $isCompany = true; } } $order_data["is_reseller"] = $isReseller; $order_data["is_company"] = $isCompany; } $order_data["user_email"] = $user->user_email; } /* Sätter momsklass i API svaret */ $taxLines = $order_data["tax_lines"]; if (!empty($taxLines)) { $taxLinesIsUpdated = false; foreach ($taxLines as &$taxLine) { $taxLabel = $taxLine["label"]; if (empty($taxLabel)) { continue; } $taxLabelArray = explode(",", $taxLabel); if (empty($taxLabelArray) || count($taxLabelArray) != 2) { continue; } $taxCode = $taxLabelArray[1]; if (empty($taxCode) && $taxCode != 0) { continue; } $taxLine["pyramid_tax_code"] = $taxCode; if (!$taxLinesIsUpdated) { $taxLinesIsUpdated = true; } } if ($taxLinesIsUpdated) { $order_data["tax_lines"] = $taxLines; } } $lineItems = $order_data["line_items"]; if (!empty($lineItems)) { $lineItemsIsUpdated = false; foreach ($lineItems as &$lineItem) { $lineTaxItems = $lineItem["taxes"]; if (!empty($lineTaxItems)) { foreach ($lineTaxItems as &$lineTaxItem) { $lineTaxItem["pyramid_tax_code"] = searchPyramidTaxCodeById($lineTaxItem["id"], $order_data["tax_lines"]); if (!$lineItemsIsUpdated) { $lineItemsIsUpdated = true; } } } else { /** * Om vi inte har några taxlines är produkten momsfri. Vi måste endå skicka med pyramid_tax_code. * Utifrån fraktsätt (instance id) kan vi sätta rätt momskod. * */ $shippingLines = $order_data["shipping_lines"]; if (!empty($shippingLines)) { /** * Finns ingen logik för fler leveranssätt. Tar första i array'en. * */ $shippingLine = $shippingLines[0]; if (!empty($shippingLine)) { $shippingInstanceId = $shippingLine["instance_id"]; /** * Svenska instance_id */ $swedishShippingIds = ["20", "27", "28", "4", "10"]; /** * EU instance id */ $euShippingIds = ["29", "30", "21"]; /** * EXPORT instance id */ $exportShippingIds = ["31", "32", "22"]; $pyramidTaxCode = null; if (in_array($shippingInstanceId, $swedishShippingIds)) { $pyramidTaxCode = "4"; } else if (in_array($shippingInstanceId, $euShippingIds)) { $pyramidTaxCode = "9"; } else if (in_array($shippingInstanceId, $exportShippingIds)) { $pyramidTaxCode = "0"; } $lineTaxItems = [ [ "pyramid_tax_code" => $pyramidTaxCode ] ]; if (!$lineItemsIsUpdated) { $lineItemsIsUpdated = true; } } } } $lineItem["taxes"] = $lineTaxItems; } if ($lineItemsIsUpdated) { $order_data["line_items"] = $lineItems; } } $response->data = $order_data; return $response; } function searchPyramidTaxCodeById($id, $array) { foreach ($array as $key => $val) { if ($val['rate_id'] === $id) { return $val['pyramid_tax_code']; } } return null; } /** * Ändra valuta symbol */ add_filter('woocommerce_currency_symbol', 'hproc_currency_symbol', 10, 2); function hproc_currency_symbol($currency_symbol, $currency) { switch ($currency) { case "SEK": $currency_symbol = "SEK"; break; case "EUR": $currency_symbol = "EUR"; break; case "NOK": $currency_symbol = "NOK"; break; case "DKK": $currency_symbol = "DKK"; break; } return $currency_symbol; } /** * Visa SKU i cart och checkout */ add_filter('woocommerce_cart_item_name', 'hproc_sku_cart_page', 99, 3); function hproc_sku_cart_page($item_name, $cart_item, $cart_item_key) { // The WC_Product object $product = $cart_item['data']; // Get the SKU $sku = $product->get_sku(); // When sku doesn't exist if (empty($sku)) return $item_name; // Add the sku $item_name .= '
' . __("SKU: ", "woocommerce") . $sku . ''; return $item_name; } /** * Skicka ett mail om ÅF ändrar billing eller shipping informationen. * https://stackoverflow.com/questions/31270846/send-notification-email-when-customer-changes-address-woocommerce */ add_action('woocommerce_customer_save_address', 'hproc_email_customer_address_change'); function hproc_email_customer_address_change() { $body = ''; $to = 'jessica.brixeby@gysinge.com'; //address that will receive this email //$to = 'patrick.andersson@100procent.com'; //address that will receive this email //$to = 'mattias@100procent.com'; //address that will receive this email $subject = 'En av återförsäljarna har uppdaterat sin adress.'; $sendNotification = false; $curr_user = wp_get_current_user(); if ($curr_user) { /** * Check if the user is retailer */ foreach ($curr_user->roles as $role) { if (substr_compare($role, "b2b", 0, 3, true) === 0 /*|| $role === "administrator"*/) { $sendNotification = true; break; } } if ($sendNotification) { $user_id = $curr_user->ID; $curr_username = $curr_user->data->user_login; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= ''; $body .= '
Konto
Användarnamn: ' . $curr_username . '
Orgaisationsnummer: ' . get_field('field_67b5b586a2d06', 'user_' . $user_id) . '
 
Faktureringsadress
Förnamn: ' . get_user_meta($user_id, 'billing_first_name', true) . '
Efternamn: ' . get_user_meta($user_id, 'billing_last_name', true) . '
Företag: ' . get_user_meta($user_id, 'billing_company', true) . '
Adress 1: ' . get_user_meta($user_id, 'billing_address_1', true) . '
Adress 2: ' . get_user_meta($user_id, 'billing_address_2', true) . '
Stad: ' . get_user_meta($user_id, 'billing_city', true) . '
Postnummer: ' . get_user_meta($user_id, 'billing_postcode', true) . '
Land: ' . get_user_meta($user_id, 'billing_country', true) . '
Telefon: ' . get_user_meta($user_id, 'billing_phone', true) . '
Email: ' . get_user_meta($user_id, 'billing_email', true) . '
 
Leveransadress
Förnamn: ' . get_user_meta($user_id, 'shipping_first_name', true) . '
Efternamn: ' . get_user_meta($user_id, 'shipping_last_name', true) . '
Företag: ' . get_user_meta($user_id, 'shipping_company', true) . '
Adress 1: ' . get_user_meta($user_id, 'shipping_address_1', true) . '
Adress 2: ' . get_user_meta($user_id, 'shipping_address_2', true) . '
Stad: ' . get_user_meta($user_id, 'shipping_city', true) . '
Postnummer: ' . get_user_meta($user_id, 'shipping_postcode', true) . '
Land: ' . get_user_meta($user_id, 'shipping_country', true) . '
'; //set content type as HTML $headers = array('Content-Type: text/html; charset=UTF-8;'); //send email if (wp_mail($to, $subject, $body, $headers)) { //echo 'email sent'; } else { //echo 'email NOT sent'; } //exit(); } } } // Enables search on headline of articles add_filter('dgwt/wcas/indexer/post_types', function ($post_types) { $post_types[] = [ 'post_type' => 'article', 'labels' => [ 'name' => 'Textartiklar', ], ]; return $post_types; }); //Enables search within the discription add_filter('dgwt/wcas/indexer/post_source_query/article/description', '__return_true'); //Showing CPT image in search result add_filter('dgwt/wcas/search_results/article/show_image', '__return_true'); // Display custom post types on the search result page add_action('woocommerce_no_products_found', function () { if (! \DgoraWcas\Helpers::isProductSearchPage()) { return; } echo do_shortcode('[fibosearch_posts_results post_type="article" layout=grid show_image]'); }); add_action('woocommerce_before_shop_loop', function () { if (! \DgoraWcas\Helpers::isProductSearchPage()) { return; } echo do_shortcode('[fibosearch_posts_results post_type="article" layout=grid show_image]'); }); ?> {"id":75681,"date":"2026-05-26T09:50:19","date_gmt":"2026-05-26T07:50:19","guid":{"rendered":"https:\/\/www.gysinge.com\/produkt\/fargprov-linoljefarg-enstaka\/"},"modified":"2026-10-30T17:05:00","modified_gmt":"2026-10-30T16:05:00","slug":"fargprov-linoljefarg-enstaka","status":"publish","type":"product","link":"https:\/\/www.gysinge.com\/en\/produkt\/fargprov-linoljefarg-enstaka\/","title":{"rendered":"F\u00e4rgprov linoljef\u00e4rg enstaka"},"content":{"rendered":"

Detta enstaka uppm\u00e5lat f\u00e4rgprov ger dig m\u00f6jlighet att se och k\u00e4nna p\u00e5 v\u00e5ra tidsenliga linoljef\u00e4rger innan du best\u00e4mmer dig f\u00f6r ditt n\u00e4sta m\u00e5larprojekt. V\u00e4lj bland v\u00e5rt noggrant utvalda sortiment av standardkul\u00f6rer och hitta den perfekta nyansen som passar just ditt hem. Med linoljef\u00e4rg f\u00e5r du inte bara en vacker finish, utan \u00e4ven en produkt som andas och skyddar dina ytor.<\/p>\n

V\u00e4lj antal kul\u00f6rprov du vill best\u00e4lla och l\u00e4gg i varukorgen.<\/p>\n

N\u00e4r du sen kommer till kassan.<\/strong><\/p>\n

Skriv i kommentarsf\u00e4ltet (Best\u00e4llningsanteckningar) vilken\/vilka kul\u00f6rer du \u00f6nskar best\u00e4lla<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"

Ett enstaka uppm\u00e5lat kul\u00f6rprov p\u00e5 en av v\u00e5ra standardkul\u00f6rer.<\/p>\n

V\u00e4lj antal kul\u00f6rprov du vill best\u00e4lla och l\u00e4gg i varukorgen.<\/p>\n

N\u00e4r du sen kommer till kassan.<\/strong><\/p>\n

Skriv i kommentarsf\u00e4ltet (Best\u00e4llningsanteckningar) vilken\/vilka kul\u00f6rer du \u00f6nskar best\u00e4lla<\/strong><\/p>\n","protected":false},"featured_media":75463,"comment_status":"open","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_members_access_role":[],"_members_access_error":""},"product_brand":[],"product_cat":[797,792,803],"product_tag":[],"class_list":["post-75681","product","type-product","status-publish","has-post-thumbnail","product_cat-linoljefarg-inomhus","product_cat-linoljefarg","product_cat-penslar-och-tillbehor","first","instock","taxable","shipping-taxable","purchasable","product-type-simple"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/product\/75681","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/types\/product"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/comments?post=75681"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/media\/75463"}],"wp:attachment":[{"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/media?parent=75681"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/product_brand?post=75681"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/product_cat?post=75681"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.gysinge.com\/en\/wp-json\/wp\/v2\/product_tag?post=75681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}