Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Shellberg tommyshellberg

View GitHub Profile
@tommyshellberg
tommyshellberg / woocommerce-xero-account-code-override-snippet.php
Last active May 4, 2022
WooCommerce Xero Override Line Item Account Code By SKU
View woocommerce-xero-account-code-override-snippet.php
add_filter('woocommerce_xero_line_item_account_code', 'wc_custom_xero_account_code', 10, 2);
function wc_custom_xero_account_code($account_code, $line_item) {
// $line_item->get_item_code() returns the SKU of the line item.
if( $line_item->get_item_code() == 'ACME') {
return '460';
}
return $account_code;
}
@tommyshellberg
tommyshellberg / wc-stripe-sofort-testing-snippet.php
Last active May 28, 2019
WooCommerce Stripe - Test a successful payment with SOFORT
View wc-stripe-sofort-testing-snippet.php
add_filter('wc_stripe_sofort_source', 'add_testing_details_sofort', 10, 2);
function add_testing_details_sofort($post_data, $order) {
$post_data['owner']->name = 'succeeding_charge';
return $post_data;
}
@tommyshellberg
tommyshellberg / PR-Stripe-Snippet.php
Created Apr 15, 2019
WooCommerce Stripe gateway - Add Puerto Rico to allowable Stripe countries
View PR-Stripe-Snippet.php
<?php
add_filter('wc_stripe_supported_countries', 'wc_stripe_add_puerto_rico');
function wc_stripe_add_puerto_rico($countries) {
$countries[] = 'PR';
return $countries;
}
@tommyshellberg
tommyshellberg / gist:aafec8ff631b2a938ba2829241ae7add
Created Sep 5, 2018
delete meta keys associated with WC Bookings if the products are missing(avoids fatal errors)
View gist:aafec8ff631b2a938ba2829241ae7add
add_action('wp', 'delete_meta_bookings_no_products');
function delete_meta_bookings_no_products() {
$booking_ids = get_posts( array(
'numberposts' => 100000,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'wc_booking',
'post_status' => get_wc_booking_statuses(),
@tommyshellberg
tommyshellberg / monthly-sales-custom-shortcode
Created Jun 11, 2018
WooCommerce - display the last 30 days of sales using shortcode
View monthly-sales-custom-shortcode
/**
* Monthly Sales Custom Shortcode
*/
add_shortcode( 'display_monthly_sales', 'print_monthly_sales_frontend' );
function print_monthly_sales_frontend() {
global $woocommerce, $wpdb, $product;
include_once($woocommerce->plugin_path() . '/includes/admin/reports/class-wc-admin-report.php');
// WooCommerce Admin Report
@tommyshellberg
tommyshellberg / gist:bec88c936f387dfd3396ae92dde3e1dc
Created Jun 6, 2018
WooCommerce - Always send Purchase Note to both Customer and Admin
View gist:bec88c936f387dfd3396ae92dde3e1dc
add_filter ('woocommerce_email_order_items_args', 'send_purchase_note_to_everyone');
function send_purchase_note_to_everyone( $args ) {
$args['show_purchase_note'] = true;
return $args;
}
@tommyshellberg
tommyshellberg / style.css
Created Jan 29, 2016
Remove white frame Artificer product
View style.css
ul.products li.product .img-wrap {
background: transparent;
-webkit-box-shadow: none;
-moz-box-shadow:none;
box-shadow: none;
}
ul.products li.product:hover .img-wrap {
background: transparent;
-webkit-box-shadow: none;
@tommyshellberg
tommyshellberg / gist:95b6ce8fcebc09236cdd
Created Apr 3, 2015
Append the WooCommerce Product Price with ' per hour' string
View gist:95b6ce8fcebc09236cdd
add_filter( 'woocommerce_get_price_html', 'custom_price_string', 100, 2 );
function custom_price_string( $price, $product ){
return $price . ' per hour';
}
@tommyshellberg
tommyshellberg / functions.php
Created Aug 8, 2014
Change the Woocommerce Bookings display price to an amount per person
View functions.php
//Place in your theme's functions.php file
function custom_booking_price( $price, $product ) {
$target_product_types = array(
'booking'
);
if ( in_array ( $product->product_type, $target_product_types ) ) {
// if variable product change price output
$price = '';
$price .= woocommerce_price($product->get_price()) . ' per person';