Skip to content

Instantly share code, notes, and snippets.

@Spreeuw
Spreeuw / functions.php
Last active February 20, 2021 18:29
WooCommerce view/filter all refunded orders (including partially refunded)
<?php
add_filter( 'views_edit-shop_order', 'wpo_wc_show_all_refunded_orders', 10, 1 );
function wpo_wc_show_all_refunded_orders ($views) {
$title = __('All refunded');
$views['all-refunded'] = sprintf( '<a href="edit.php?post_status=wc-refunded&post_type=shop_order&all-refunded=true">%s</a>', $title );
return $views;
}
add_filter( 'request', 'wpo_wc_show_all_refunded_orders_request' );
function wpo_wc_show_all_refunded_orders_request( $query_vars ) {
@Spreeuw
Spreeuw / functions.php
Last active April 29, 2020 15:42
WooCommerce Bulk send order details
<?php
add_action( 'bulk_actions-edit-shop_order', 'woocommerce_bulk_actions_order_emails', 10 );
function woocommerce_bulk_actions_order_emails( $actions ) {
$actions['send_order_details'] = __( 'Email invoice / order details to customer', 'woocommerce' );
return $actions;
}
add_filter( 'handle_bulk_actions-edit-shop_order', 'woocommerce_bulk_actions_order_emails_handle', 10, 3 );
function woocommerce_bulk_actions_order_emails_handle( $redirect_to, $action, $post_ids ) {
if ( $action !== 'send_order_details' ) {
<?php
add_action('woocommerce_order_item_add_action_buttons','wpo_bulk_edit_line_item_prices',10,1);
function wpo_bulk_edit_line_item_prices($order) {
?>
<input type="text" class="bulk-multiply-items-multiplier" size="5" style="float:left;"><button type="button" class="button bulk-multiply-items">multiply prices</button>
<script>
jQuery(function($) {
$('.button.bulk-multiply-items').click(function(event){
event.preventDefault();
var multiplier = parseFloat( $('.bulk-multiply-items-multiplier').val() );
<?php if( !empty( $post_meta ) ) { ?>
<table class="widefat striped" style="font-family:monospace; text-align:left; width:100%;">
<tbody>
<?php foreach( $post_meta as $meta_name => $meta_value ) { ?>
<?php
if( count( maybe_unserialize( $meta_value ) ) == 1 )
$meta_value = $meta_value[0];
$meta_value = maybe_unserialize( $meta_value );
?>
@Spreeuw
Spreeuw / dokan-invoice-filters.php
Last active June 23, 2020 06:28
Dokan PDF Invoices
<?php
/*******************************
** DOKAN PDF INVOICE FILTERS **
*******************************/
/**
* Replace the main shop name with "Store Info" (actual shop name listed below)
*/
add_filter( 'wpo_wcpdf_shop_name', 'wpo_wcpdf_add_dokan_shop_name', 10, 1 );
function wpo_wcpdf_add_dokan_shop_name ( $shop_name ) {
@Spreeuw
Spreeuw / functions.php
Created August 4, 2015 11:39
link to hide completed orders in woocommerce
<?php
add_filter( 'views_edit-shop_order', 'wc_hide_completed_link', 10, 1 );
function wc_hide_completed_link ($views) {
$views['exclude-completed'] = sprintf('<a href="edit.php?exclude_order_status=wc-completed&post_type=shop_order">Hide completed orders</a>');
return $views;
}
add_action( 'load-edit.php', 'wc_filter_completed' );
function wc_filter_completed() {
global $typenow;
@Spreeuw
Spreeuw / functions.php
Created December 18, 2014 15:09
Replace Menu Cart Pro link item with two buttons linking to the cart and checkout #wpovernight #menucart #menucartpro
add_filter( 'wpmenucart_cart_link_item', 'wpmenucart_cart_checkout_buttons', 10, 1 );
function wpmenucart_cart_checkout_buttons($cart_link_item) {
global $woocommerce;
// get urls
$checkout_url = $woocommerce->cart->get_checkout_url();
$cart_url = $woocommerce->cart->get_cart_url();
// make buttons