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 March 11, 2022 11:16
nShift Unifaun - returnPart
<?php
/**
* @snippet WooCommerce - Sets custom returnpart in Unifaun
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 6.2.0
*/
function redlight_unifaun_bring_return_part( $shipment, $order ) {
if( 'PNL342' === $shipment['service']['id'] ){
$shipment['returnPart']['quickId'] = 'RETURNPART1';
@hedqvist
hedqvist / functions.php
Created June 15, 2021 13:31
PostNord - labelType
<?php
/**
* @snippet WooCommerce - Set labelType to Small when getting labels from PostNord
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 5.2.0
*/
function redlight_postnord_labelType( $labelType, $order ) {
$labelType = 'small';
return $labelType;
}
@hedqvist
hedqvist / functions.php
Last active February 25, 2021 11:33
Unifaun - PostNord liggtid
<?php
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.2.0
*/
function redlight_unifaun_postnord_addon( $shipment, $order ) {
// Only P19
if( 'P19' === $shipment['service']['id'] ){
$shipment['service']['addons'][] = array(
@hedqvist
hedqvist / functions.php
Created December 6, 2020 14:04
Order Reviews - Custom Title
<?php
add_filter('wp_title','custom_reviews_title',99,1);
add_filter('pre_get_document_title', 'custom_reviews_title',99,1);
function custom_reviews_title($title){
if (function_exists('wcor_is_feedback_page')) {
if ( wcor_is_feedback_page() ) {
$title='Order Review Page Title'; //define your title here
}
}
return $title;
@hedqvist
hedqvist / functions.php
Created November 9, 2020 09:11
Fortnox - Reference
<?php
/**
* @snippet WooCommerce - Adds Custom reference on order
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.7.0
*/
function redlight_fortnox_custom_reference( $orderData, $order_id) {
$order = wc_get_order($order_id);
$orderData['Order']['YourReference'] = '';
if($order->get_meta('_custom_reference')){
@hedqvist
hedqvist / functions.php
Created October 28, 2020 13:42
Unifaun - Best Transport NoSIGN
<?php
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.0.1
*/
function redlight_unifaun_best_nosign( $shipment, $order ) {
// Only Best Hemleverans SMALL
if( 'BESTHLE' === $shipment['service']['id'] ){
$shipment['service']['addons'][] = array(
@hedqvist
hedqvist / functions.php
Created October 22, 2020 06:59
Unifaun - Schenker Return Print
<?
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_unifaun_bhp_return_print( $shipment, $order ) {
// Only Schenker Ombud
if( 'BHP' === $shipment['service']['id'] ){
$shipment['service']['addons'][] = array(
@hedqvist
hedqvist / functions.php
Created October 14, 2020 13:03
Order Reviews - Translate text
<?php
/**
* @snippet WooCommerce - Translate any text :)
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.6.0
*/
add_filter('gettext', 'translate_update_review_text');
add_filter('ngettext', 'translate_update_review_text');
function translate_myText($translated) {
$translated = str_ireplace('Hi %s! We hope that you are satisfied with your purchase with us at %s. We would to know if you would like to update your review.', '%s, do you want to update your review?', $translated);
@hedqvist
hedqvist / functions.php
Created October 13, 2020 14:16
Fortnox - Account Depending on VAT
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Set Accountnumber depending on VAT
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.6.0
*/
function redlight_fortnox_account_based_on_vat($orderData) {
foreach($orderData['Order']['OrderRows'] as $i => $item) {
if( $item['VAT'] == 25 ){
$orderData['Order']['OrderRows'][$i]['AccountNumber'] = 3001;
@hedqvist
hedqvist / functions.php
Last active December 10, 2020 19:43
Order Reviews - Skip certain product
<?php
/**
* @snippet WooCommerce - Order Reviews - Skip certain products
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.5.1
*/
function redlight_order_reviews_skip_certain_product( $skip, $product, $order, $line_item ) {
$line_item_data = $line_item->get_data();
//$line_item_data['product_id'] - This now contains our product since variables doesnt support terms