Skip to content

Instantly share code, notes, and snippets.

View hedqvist's full-sized avatar

Christopher Hedqvist hedqvist

View GitHub Profile
@hedqvist
hedqvist / functions.php
Last active December 10, 2024 12:52
Fortnox - Set Email Address to billing email
<?php
/**
* @snippet WooCommerce -Fortnox - Set customers email to Order billing emailing
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_fortnox_order_email_to( $orderData, $order_id) {
$order = wc_get_order($order_id);
$orderData['Order']['EmailInformation']['EmailAddressTo'] = $order->get_billing_email();
@hedqvist
hedqvist / functions.php
Last active January 29, 2020 10:04
Unifaun - Adds Insurance AddOn
<?
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_unifaun_aspo_insurance( $shipment, $order ) {
// Only DHL Service Point
if($order->get_total() < 2000 ){
return $shipment;
@hedqvist
hedqvist / functions.php
Created January 23, 2020 18:18
Unifaun - Remove CustomsDeclaration for EU countries
<?php
/**
* @snippet WooCommerce - Removes customsDeclaration for EU-countries
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.7.0
*/
function redlight_unifaun_remove_customs_in_eu( $shipment, $order ) {
$EU_countries = apply_filters( 'woocommerce_eu_vat_number_country_codes', array(
'AT',
'BE',
@hedqvist
hedqvist / functions.php
Last active May 22, 2020 13:08
Unifaun - Customs value
<?php
/**
* @snippet WooCommerce -Unifaun - Set Customs Line Value
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_unifaun_customs_line_value( $line, $shipment, $order, $product, $item ) {
//$order = new WC_Order($order_id);
$line['value'] = '400';
@hedqvist
hedqvist / functions.php
Created January 23, 2020 10:43
Unifaun - Customs Declaration type - Gift
<?php
/**
* @snippet WooCommerce -Unifaun - Set Customs importExportType
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_unifaun_customs_type( $customsDeclaration, $shipment, $order_id) {
//$order = new WC_Order($order_id);
$customsDeclaration['importExportType'] = 'gift';
@hedqvist
hedqvist / functions.php
Created January 22, 2020 14:43
Support for WooCommerce Shipment Tracking
<?php
/**
* @snippet WooCommerce - Unifaun plugin by Redlight Media - Add Support for WooCommerce Shipment Tracking
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
add_action( 'ac_wc_unifaun_shipment_print_successful_print', 'redlight_postnord_add_tracking', 10, 3 );
function redlight_postnord_add_tracking($body, $response, $order){
$provider = 'PostNord Sverige AB';
if ( isset( $body->pdfs ) ) {
@hedqvist
hedqvist / functions.php
Last active June 17, 2020 12:54
Unifaun Fix for CDON (Sharespine)
<?php
/**
* @snippet WooCommerce - Unifaun plugin by Redlight Media - Add default shipping method to orders missing shipping
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.2.0
*/
add_filter( 'ac_wc_unifaun_order_list_shipping_method_id', 'redlight_unifaun_order_list_method_id', 10, 2);
add_filter( 'ac_wc_unifaun_post_shipment_shipping_method_id', 'redlight_unifaun_order_list_method_id', 10, 2);
add_filter( 'ac_wc_unifaun_post_return_shipment_shipping_method_id', 'redlight_unifaun_order_list_method_id', 10, 2);
function redlight_unifaun_order_list_method_id( $method_id , $order ) {
@hedqvist
hedqvist / functions.php
Last active April 22, 2024 12:35
Unifaun/Pacsoft - Add track and trace to completed email
<?php
/**
* @snippet WooCommerce - Unifaun plugin by Redlight Media - Add Track & Trace url to completed email
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.8.1
*/
function redlight_add_tracking_url_to_completed_email( $order, $sent_to_admin, $plain_text, $email ) {
if ( $email->id == 'customer_completed_order' ) {
if (function_exists('wcuns')) {
@hedqvist
hedqvist / functions.php
Created December 2, 2019 17:01
Fortnox - Customer Type
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - (REGISTRED USERS) Set customer Type to Private
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.8.0
*/
function redlight_custom_customer_type( $customer) {
$customer['Customer']['Type'] = 'PRIVATE';
@hedqvist
hedqvist / functions.php
Created December 2, 2019 16:59
Fortnox - Set Customer type (GUEST)
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - (GUEST USERS) Set customer Type to Private
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.4.2
*/
function redlight_fortnox_guest_customer_type( $customer, $order_id ) {
$customer['Customer']['Type'] = 'PRIVATE';
return $customer;