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
Created June 10, 2020 08:24
Swish - Disable Cancel function
<?php
/**
* @snippet WooCommerce - Swish ECommerce - Dont cancel payments
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.2.0
*/
add_filter( 'redlight_swish_ecommerce_cancel_payment', '__return_false' );
@hedqvist
hedqvist / functions.php
Created June 3, 2020 08:43
Fortnox - Order meta
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Add Ordermeta to field in Fortnox
* @compatible WooCommerce 4.1.1
*/
function redlight_fortnox_doorcode( $orderData, $order_id) {
$order = new WC_Order($order_id);
$doorcode = $order->get_meta('_doorcode', true);
if($doorcode){
$orderData['Order']['Remarks'] .= "\r\n"."Portkod: ".$doorcode;
@hedqvist
hedqvist / functions.php
Last active September 22, 2022 12:43
Unifaun - Bring Addons
<?php
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.0.1
*/
function redlight_unifaun_bring_notification( $shipment, $order ) {
// Only BCSEDSTD and 'PAKET MED HEMLEVERANS'
if( 'BCSEDSTD' === $shipment['service']['id'] && 'PAKET MED HEMLEVERANS' === $order->get_shipping_method()){
$shipment['service']['addons'][] = array(
@hedqvist
hedqvist / functions.php
Created June 2, 2020 09:10
Fortnox - Shipping as OrderItem EU
<?php
/**
* @snippet WooCommerce - Fortnox Add Shipping charges as OrderItem instead of Shipping fee in Fortnox
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.1.0
*/
function redlight_fortnox_shipping_as_order_item($orderData, $order_id) {
$order = new WC_Order($order_id);
// Remove fee from orderData
if(isset($orderData['Order']['Freight'])){
@hedqvist
hedqvist / functions.php
Created May 29, 2020 13:41
Unifaun - PickupBooking
<?php
/**
* @snippet WooCommerce - Book Pickup
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.1.1
*/
function redlight_unifaun_pickup_booking( $shipment, $order ) {
$shipment['service']['pickupBooking'] = true;
return $shipment;
}
@hedqvist
hedqvist / functions.php
Created May 29, 2020 09:16
Fortnox - Dont Complete Order
<?php
/**
* @snippet WooCommerce -Fortnox - Mark order as not-completed
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.1.1
*/
function redlight_fortnox_order_notcompleted( $orderData, $order_id) {
//$order = new WC_Order($order_id);
$orderData['Order']['NotCompleted'] = true;
@hedqvist
hedqvist / functions.php
Created May 28, 2020 14:36
Unifaun - DHL GREEN Addon
<?php
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.1.1
*/
function redlight_unifaun_dhl_green( $shipment, $order ) {
// Only APC service ID (DHL Parcel Connect)
if( 'APC' === $shipment['service']['id'] ){
$shipment['service']['addons'][] = array(
@hedqvist
hedqvist / functions.php
Created May 22, 2020 13:07
Unifaun - Declarant Date
<?php
/**
* @snippet WooCommerce -Unifaun - Set Customs declarantDate to todays Date
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_unifaun_customs_date( $customsDeclaration, $shipment, $order_id) {
$customsDeclaration['declarantDate'] = date('Y-m-d');
return $customsDeclaration;
@hedqvist
hedqvist / functions.php
Last active May 22, 2020 13:08
Unifaun - GrossWeight equal to NetWeight
<?php
/**
* @snippet WooCommerce -Unifaun - Set Customs Line GrossWeight equal to NetWeight
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_unifaun_customs_line_grossweight( $line, $shipment, $order, $product, $item ) {
$line['grossWeight'] = $line['netWeight'];
return $line;
@hedqvist
hedqvist / Functions.php
Created May 22, 2020 08:11
Unifaun - Printing favorite
<?php
/**
* @snippet WooCommerce - Set favorite
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_unifaun_favorite( $shipment, $order ) {
$shipment['favorite'] = 'min favorit';
return $shipment;