This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_order_actions_start', function() { | |
global $post_id; | |
$order = new WC_Order( $post_id ); | |
if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Order::order_contains_subscription( $order ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Put the following in your theme's functions.php for instance: | |
add_filter( 'wc_pdf_product_vouchers_voucher_fields', 'wc_pdf_product_vouchers_add_custom_fields', 10, 2 ); | |
/** | |
* Adds some custom fields to the given product voucher | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_single_product_summary', 'show_product_cost', 15 ); | |
function show_product_cost() { | |
global $product; | |
$item_cost = get_post_meta( $product->id, '_wc_cog_cost', true ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wc_sequential_order_numbers_is_free_order', 'wc_sequential_order_numbers_is_free_order', 10, 2 ); | |
function wc_sequential_order_numbers_is_free_order( $is_free, $order_id ) { | |
if ( $is_free ) { | |
$order = new WC_Order( $order_id ); | |
// lets make sure the items truly are free, and not just on sale, or discounted with a coupon | |
foreach ( $order->get_items() as $item ) { | |
$product = $order->get_product_from_item( $item ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_get_price_html', 'wc_hide_product_page_price_per_unit', 11, 2 ); | |
function wc_hide_product_page_price_per_unit( $price_html, $product ) { | |
// if this is a product variation, get the parent product which holds the calculator settings | |
$_product = $product; | |
if ( isset( $product->variation_id ) && $product->variation_id ) { $_product = WC_Price_Calculator_Product::get_product( $product->id ); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_catalog_settings', 'add_woocommerce_weight_unit_xx' ); | |
/** | |
* This adds the new unit to the WooCommerce admin | |
*/ | |
function add_woocommerce_weight_unit_xx( $settings ) { | |
foreach ( $settings as &$setting ) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'plugins_url', 'allow_symlink_plugins_url', 10, 3 ); | |
/** | |
* Allow symlinked plugins to function. This was made necessary by a change in | |
* the standard WooCommerce plugin_url() method from: | |
* | |
* plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ); | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function woocommerce_subcategory_thumbnail( $category ) { | |
global $woocommerce; | |
// Modification: don't show the image for subcategories | |
if ( $category->parent ) return; | |
$small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'shop_catalog' ); | |
$image_width = $woocommerce->get_image_size( 'shop_catalog_image_width' ); | |
$image_height = $woocommerce->get_image_size( 'shop_catalog_image_height' ); |
NewerOlder