Skip to content

Instantly share code, notes, and snippets.

@georgybu
georgybu / content-single-product.php
Created December 14, 2012 12:09
WooCommerce - Show next\prev products from current product category (when viewing a single product) 1. If product is last -> Next product is first 2. If product is first -> Prev product is last forked from https://gist.github.com/2176823 (This question was in http://stackoverflow.com/questions/13597687/woocommerce-get-next-previous-product/13612387
<?php
// get next and prev products
// Author: Georgy Bunin (bunin.co.il@gmail.com)
// forked from https://gist.github.com/2176823
function ShowLinkToProduct($post_id, $categories_as_array, $label) {
// get post according post id
$query_args = array( 'post__in' => array($post_id), 'posts_per_page' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
array(
'taxonomy' => 'product_cat',
@kloon
kloon / functions.php
Last active March 4, 2024 19:36
WooCommerce total order weight column on orders page
<?php
add_filter( 'manage_edit-shop_order_columns', 'woo_order_weight_column' );
function woo_order_weight_column( $columns ) {
$columns['total_weight'] = __( 'Weight', 'woocommerce' );
return $columns;
}
add_action( 'manage_shop_order_posts_custom_column', 'woo_custom_order_weight_column', 2 );
function woo_custom_order_weight_column( $column ) {
global $post, $woocommerce, $the_order;
@maxrice
maxrice / wc-hide-coupons-cart-checkout.php
Created January 21, 2014 23:43
WooCommerce - hide the coupon form on the cart or checkout page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons
<?php
// hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
@kloon
kloon / functions.php
Created January 22, 2014 13:16
WooCommerce add order notes to completed emails
<?php
// Add an order notes section to customers' completed emails
add_action( 'woocommerce_email_after_order_table', 'wc_add_order_notes_to_completed_emails', 10, 1 );
function wc_add_order_notes_to_completed_emails( $order ) {
if ( 'completed' == $order->status ) {
echo '<h2>' . __( 'Order Notes', 'woocommerce' ) . '</h2>';
$order_notes = $order->get_customer_order_notes();
foreach ( $order_notes as $order_note ) {
echo '<p>' . $order_note->comment_content . '<p>';
}
@bekarice
bekarice / wc-email-create-account-section.php
Last active December 14, 2019 17:59
Adds a "Create an account" section to WooCommerce guest customer emails
<?php
/**
* Adds a "Create an account?" section to customer emails
* Only added for emails sent to guest purchases
*
* @param \WC_Order $order the order object
* @param bool $sent_to_admin false if emails are sent to customers
* @param bool $plain_text false for HTML emails
*/
function sv_add_email_register_section( $order, $sent_to_admin, $plain_text ) {
@bekarice
bekarice / wc-my-account-prefill-email.php
Created January 18, 2016 03:27
Sets the email $_POST value so WC will prefill the "email" field in the My Account registration form
<?php
// get the email param if it's set so the registration form can use it
function sv_get_account_email_param() {
$_POST['email'] = isset( $_GET['email'] ) ? urldecode( $_GET['email'] ) : false;
}
add_action( 'woocommerce_register_form_start', 'sv_get_account_email_param' );
@bekarice
bekarice / woocommerce-updated-email-order-items-table.php
Created March 30, 2016 05:37
WooCommerce Order Emails: Add product images to the order email (WooCommerce 2.5+)
<?php // only copy this line if needed
/**
* Adds product images to the WooCommerce order emails table
* Uses WooCommerce 2.5 or newer
*
* @param string $output the buffered email order items content
* @param \WC_Order $order
* @return $output the updated output
*/
function sww_add_images_woocommerce_emails( $output, $order ) {
@rynaldos-zz
rynaldos-zz / wc-custom-purchased-column.php
Last active June 15, 2020 06:26
[WooCommerce 3.0+] Re-instate the "Purchased items" column on orders page
add_filter('manage_edit-shop_order_columns', 'wc_custom_purchased_column');
function wc_custom_purchased_column($columns)
{
$new_array = array();
foreach ($columns as $key => $title) {
if ($key == 'billing_address') {
$new_array['order_items'] = __('Purchased', 'woocommerce');
}
@prikhi
prikhi / wc-custom-purchased-column.php
Last active June 15, 2020 06:24 — forked from rynaldos-zz/wc-custom-purchased-column.php
[WooCommerce 3.0+] Re-instate the "Purchased items" column on orders page
<?php
/** Add a Purchased Column w/ Item Quantity, SKU, Name, & Meta to the Admin Orders Table **/
class ThemeWooCommerce
{
/* Add a `Purchased` Column to the Admin Orders Table */
public static function add_purchased_column_header($columns) {
$new_columns = array();
foreach ($columns as $key => $title) {
if ($key === 'billing_address') {
$new_columns['order_items'] = __('Purchased', 'woocommerce');
@simivar
simivar / print_r_reverse.php
Last active November 4, 2023 23:27
PHP function to reverse print_r function
<?php
/**
* I've published a fully-tested Composer library with type-casting.
* @see https://github.com/simivar/reverse-print-r
*/
/**
* Matt: core
* Trixor: object handling
* lech: Windows suppport