Last active
September 4, 2020 15:51
-
-
Save helgatheviking/a4e81ae4b600d8d17b119069dbca2d1f to your computer and use it in GitHub Desktop.
Add support for Mix and Match products to PluginHive UPS
This file contains 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: WooCommerce Mix and Match - PluginHive UPS Bridge | |
* Plugin URI: http://www.woocommerce.com/products/woocommerce-mix-and-match-products/ | |
* Description: Add support for Mix and Match products to UPS shipping. | |
* Version: 1.0.0 | |
* Author: Kathy Darling | |
* Author URI: http://kathyisawesome.com/ | |
* WC requires at least: 4.0.0 | |
* WC tested up to: 4.4.0 | |
* | |
* @author Kathy Darling | |
* @category Core | |
* @package WC MNM + UPS Bridge | |
* | |
* Copyright: © 2020 Kathy Darling | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
defined( 'ABSPATH' ) || exit; | |
/** | |
* Modify the returned order items and products to return the correct items/weights/values for shipping. | |
*/ | |
function kia_mnm_ups_compat_init() { | |
add_action( 'ph_ups_before_get_items_from_order', 'kia_mnm_ups_compat_add_filters' ); | |
//add_action( 'ph_ups_after_get_items_from_order', 'kia_mnm_ups_compat_remove_filters' ); | |
} | |
add_action( 'woocommerce_mnm_loaded', 'kia_mnm_ups_compat_init' ); | |
function kia_mnm_ups_compat_add_filters() { | |
add_filter( 'woocommerce_order_get_items', array( WC_Mix_and_Match()->order, 'get_order_items' ), 10, 2 ); | |
add_filter( 'woocommerce_order_item_product', array( WC_Mix_and_Match()->order, 'get_product_from_item' ), 10, 2 ); | |
} | |
function kia_mnm_ups_compat_remove_filters() { | |
remove_filter( 'woocommerce_order_get_items', array( WC_Mix_and_Match()->order, 'get_order_items' ), 10, 2 ); | |
remove_filter( 'woocommerce_order_item_product', array( WC_Mix_and_Match()->order, 'get_product_from_item' ), 10, 2 ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment