Skip to content

Instantly share code, notes, and snippets.

@rayflores
Created September 21, 2017 18:38
Show Gist options
  • Save rayflores/cf9c3e2645690d4941142bc2ec78419d to your computer and use it in GitHub Desktop.
Save rayflores/cf9c3e2645690d4941142bc2ec78419d to your computer and use it in GitHub Desktop.
WooCommerce Rearrange Product Addons
<?php
/*
Plugin Name: WooCommerce Rearrange Product Addons
*/
$GLOBALS['Product_Addon_Display']; // get globals
// if variations - remove from single variation hook
function remove_plugin_actions(){
remove_action( 'woocommerce_single_variation', array( $GLOBALS['Product_Addon_Display'], 'display' ), 15);
}
add_action('woocommerce_single_variation','remove_plugin_actions');
// if variations - remove from displaying at all
function remove_display(){
remove_action( 'woocommerce_before_variations_form', array( $GLOBALS['Product_Addon_Display'], 'reposition_display_for_variable_product' ), 10 );
}
add_action('woocommerce_before_variations_form','remove_display');
// add display where you want to (
/* TODO: add settings to get hook here */
function add_display(){
$GLOBALS['Product_Addon_Display']->display();
}
add_action( 'woocommerce_before_add_to_cart_button', 'add_display' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment