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 2, 2020 10:17
Fortnox - Get Stock amount from special stockpoint
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Hämta lagersaldo från en specifik lagerplats
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.5.8
*/
function redlight_fortnox_warehouse_stock_point_amount ( $DisposableQuantity, $WC_Product, $fortnox_article ) {
$articleNumber = $WC_Product->get_meta( '_obj_fortnox_article_number', true );
//Vår Lagerplats
$stockpoint = 'LAGER';
@hedqvist
hedqvist / functions.php
Last active May 14, 2020 08:08
Unifaun - Declaration value before discounts
<?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 ) {
$line['value'] = $item->get_subtotal() - $item->get_subtotal_tax();
return $line;
@hedqvist
hedqvist / functions.php
Last active May 14, 2020 08:10
Unifaun - Declaration value from product
<?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 ) {
$line['value'] = $product->get_price();
return $line;
}
@hedqvist
hedqvist / functions.php
Last active March 5, 2021 12:11
Unifaun - Set Dimensions
<?php
/**
* @snippet WooCommerce - Adds Dimensions to Schenker Parcel
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.5.3
*/
function redlight_unifaun_dimensions( $shipment, $order) {
if( 'AIRMEE' === $shipment['service']['id'] ){
foreach( $shipment['parcels'] as $i => $parcel ) {
$shipment['parcels'][$i]['length'] = 150;
@hedqvist
hedqvist / functions.php
Last active February 8, 2021 09:02
WP Overnight - Barcode in Invoice
<?php
function redlight_overnight_barcode_scanner_wc_barcode( $template_type, $order ) {
if(function_exists('WC_Order_Barcodes')){
echo '<style type="text/css">.barcode>img{max-width:100%;max-height:100%;}</style>';
echo '<div class="barcode" style="width:250px;text-align: center;">';
echo WC_Order_Barcodes()->display_barcode($order->get_id(),$order->get_order_number(),'',true);
echo '</div>';
}
}
@hedqvist
hedqvist / functions.php
Created March 31, 2020 18:48
Unifaun - Varubrev Corona - Lämnas vid dörr
<?php
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.0.1
*/
function redlight_unifaun_varubrev_covid19( $shipment, $order ) {
// Only PUA
if( 'PUA' === $shipment['service']['id']){
$shipment['service']['addons'][] = array(
@hedqvist
hedqvist / functions.php
Created March 31, 2020 13:00
Unifaun - Addon based on delivery name
<?php
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.0.1
*/
function redlight_unifaun_varubrev_corona( $shipment, $order ) {
// Only PUA and 'Varubrev - Lämnas vid dörr'
if( 'PUA' === $shipment['service']['id'] && 'Varubrev - Lämnas vid dörr' === $order->get_shipping_method()){
$shipment['service']['addons'][] = array(
@hedqvist
hedqvist / functions.php
Created March 27, 2020 14:26
Unifaun - Budbee Delivery without Proof of Delivery
<?php
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.0.1
*/
function redlight_unifaun_budbee_pod( $shipment, $order ) {
// Only Budbee Flex
if( 'BUDBEEDLVEVN ' === $shipment['service']['id'] ){
$shipment['service']['addons'][] = array(
@hedqvist
hedqvist / functions.php
Created March 26, 2020 10:23
Fortnox - Dont sync customers
<?php
/**
* @snippet WooCommerce - Fortnox - Dont sync customers, ever
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.8.0
*/
add_filter( 'obj_fortnox_sync_guest_user', '__return_false' );
add_filter( 'obj_fortnox_sync_user', '__return_false' );
@hedqvist
hedqvist / functions.php
Last active April 9, 2023 13:11
Fortnox - Personnummer
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Add custom field to Fortnox via functions.php
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.5.2
*/
function redlight_fortnox_pnr_guest_customer( $customer, $order_id ) {
$organisationsnummer = get_post_meta($order_id, 'organisationsnummer', true);
if(!empty($organisationsnummer)){