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 // only copy if needed | |
/** | |
* Example: Add order meta to the REST API | |
* WC 2.6+ | |
* | |
* @param \WP_REST_Response $response The response object. | |
* @param \WP_Post $post Post object. | |
* @param \WP_REST_Request $request Request object. | |
* @return object updated response object |
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 // only copy this line if needed | |
/** | |
* Example 1: Changes the separator between variations in a generated SKU | |
* | |
* @param string $separator the original separator | |
* @return string the new separator | |
*/ | |
function sv_wc_replace_variation_sku_separator( $separator ) { | |
return '_'; |
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 | |
/** | |
* Plugin Name: Registration Order Link for WooCommerce | |
* Plugin URI: http://skyver.ge/5S | |
* Description: Automatically links previous orders to new customer accounts upon WooCommerce registration. | |
* Author: SkyVerge | |
* Author URI: http://www.skyverge.com/ | |
* Version: 1.0.0 | |
* Text Domain: link-wc-orders | |
* |
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 // only copy if needed | |
/** | |
* Add a custom action to order actions select box on edit order page | |
* Only added for paid orders that haven't fired this action yet | |
* | |
* @param array $actions order actions array to display | |
* @return array - updated actions | |
*/ | |
function sv_wc_add_order_meta_box_action( $actions ) { |
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 // only copy if needed | |
/** | |
* Hides any non-free shipping methods if free shipping is available | |
* | |
* @param array $rates array of \WC_Shipping_Rate objects that apply to the cart | |
* @return array - the updated available rates | |
*/ | |
function sww_wc_hide_non_free_shipping( $rates ) { |
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 custom column headers | |
function wc_csv_export_modify_column_headers( $column_headers ) { | |
$new_headers = array( | |
'column_1' => 'Column 1', | |
'column_2' => 'Column 2', | |
// add other column headers here in the format column_key => Column Name | |
); | |
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 // only copy this line if needed | |
/** | |
* Renders a notice and prevents checkout if the cart | |
* only contains products in a specific category | |
*/ | |
function sv_wc_prevent_checkout_for_category() { | |
// set the slug of the category for which we disallow checkout | |
$category = 'clothing'; |
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 // only copy if needed | |
/** | |
* Adds randomized product sorting option to WooCommerce stores (WC 2.3+) | |
* | |
* @param array $sortby the orderby options for product sorting | |
* @return array - updated sorting options | |
*/ | |
function sv_random_woocommerce_catalog_orderby( $sortby ) { | |
$sortby['rand'] = __( 'Sort by: random order', 'my-textdomain' ); |
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 | |
/** | |
* Helper function to get all active memberships for a user | |
* | |
* @param int|\WP_User $user_id Optional, defaults to current user | |
* @return array - empty array|array of active memberships for the user | |
*/ | |
function sv_wc_memberships_get_active_memberships( $user_id = null ) { |