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 November 26, 2020 11:16
Set TermsOfPayment depending on payment method
<?
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Set TermsOfPayment depending on payment method via functions.php
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.2.5
*/
function redlight_fortnox_payment_method_TermsOfPayment($orderData, $order_id) {
$order = wc_get_order($order_id);
$order_payment_method = $order->get_payment_method();
switch( $order_payment_method ) {
@hedqvist
hedqvist / functions.php
Created January 5, 2018 20:05
Remove Postmeta from OrderItem
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Remove and Post_meta rows in Fortnox via functions.php
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.2.5
*/
function redlight_fortnox_remove_postmeta($orderData) {
foreach($orderData['Order']['OrderRows'] as $i => $item) {
if(isset($item['AccountNumber']) && $item['AccountNumber'] == 'API_BLANK')
@hedqvist
hedqvist / functions.php
Last active July 12, 2018 14:44
Shipping Fee to OrderRow in Fortnox
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Add Shipping charges as OrderItem instead of Shipping fee in Fortnox via functions.php
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.2.5
*/
function redlight_fortnox_shipping_as_orderLine($orderData, $order_id) {
$order = new WC_Order($order_id);
// Remove fee from orderData
@hedqvist
hedqvist / functions.php
Created December 13, 2017 22:24
Klarna reference to Fortnox ExternalInvoiceReference1 & ExternalInvoiceReference2
<?
/**
* @snippet WooCommerce - Adds Klarna Invoice and ordernumber to Fortnox ExternalInvoiceReference1 & ExternalInvoiceReference2 fields
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.2.5
*/
function redlight_fortnox_klarna_invoice_order_reference( $orderData, $order_id) {
$order = new WC_Order($order_id);
if($order->get_payment_method() == 'klarna_checkout'){