Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add product SKU underneath the product title on an order form from Order Form for WooCommerce. Requires version 1.0.5 or higher. Save this file as a simple plugin in the WordPress plugins folder. http://orderform-woo.webaware.net.au/
<?php
/*
Plugin Name: Order Form for WooCommerce SKU
Plugin URI: https://gist.github.com/webaware/7a8974a88caf4bcb3eed
Description: add product SKU to Order Form for WooCommerce product
Author: WebAware
Author URI: http://webaware.com.au/
*/
if (!defined('ABSPATH')) {
exit;
}
/**
* add product SKU to Order Form for WooCommerce product
* @param WC_Product $product
* @param array $attrs
*/
add_action('orderform_woocommerce_order_item_end', function($product, $attrs) {
$sku = $product->get_sku();
if (wc_product_sku_enabled() && ($sku || $product->is_type('variable'))):
if (empty($sku)) {
$sku = __('N/A', 'woocommerce');
}
?>
<br />
<span class="sku_wrapper"><?php _e( 'SKU:', 'woocommerce' ); ?> <span class="sku" itemprop="sku"><?php echo $sku; ?></span>.</span>
<?php
endif;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.