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 | |
add_filter( 'wc_product_table_query_args', function( $args, WC_Product_Table_Query $wpt_query ) { | |
// The 'args' property - type WC_Product_Table_Args - contains all the shortcode options used to create the table. | |
// Example checking the category option... | |
if ( 'something' === $wpt_query->args->category ) { | |
// Do something with the query args for this table | |
} | |
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 | |
final class Quick_View_Plugin { | |
const NAME = 'WooCommerce Quick View Pro'; // should match download name in EDD | |
const VERSION = '1.1'; | |
const FILE = __FILE__; | |
private static $BASENAME = null; | |
/* The plugin license manager. */ |
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 | |
class My_WooCommerce_Plugin implements Registerable { | |
const ITEM_ID = 1234; // The Download ID in EDD | |
const NAME = 'My Cool Plugin'; | |
const VERSION = '1.0'; | |
const FILE = __FILE__; | |
private $license_controller; |
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
/** | |
* Parse a form to an object in the format: { input1: 'value', input2: 'some value', etc }. | |
* | |
* @param {jQuery} $form The form to parse | |
* @returns {Object} The serialized form | |
*/ | |
function serializeForm( $form ) { | |
var serialized = $form.serializeArray(), | |
s = '', name = '', prefix = '', index = 0, | |
data = { }, arrayNames = { }; |
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 | |
add_action( 'wp_head', function() { | |
if ( class_exists( 'WC_Product_Table_Plugin' ) ) { | |
echo '<link rel="preload" href="' . plugins_url( 'assets/fonts/fa-solid-900.woff2', WC_Product_Table_Plugin::FILE ) . '" as="font" type="font/woff2" crossorigin="anonymous">' . "\n"; | |
} | |
} ); |
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 | |
add_filter( 'body_class', function( $classes ) { | |
if ( function_exists( 'is_shop' ) && is_shop() ) { | |
$classes = array_diff( $classes, array( 'wc-add-to-cart-no-text' ) ); | |
} | |
return $classes; | |
}, 20 ); |
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 | |
add_action( 'template_redirect', function() { | |
if ( ! is_front_page() ) { | |
add_filter( 'wc_product_table_open_products_in_new_tab', '__return_true' ); | |
} | |
} ); |
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 | |
// Assuming you have cf:_regular_price as a column in your table... | |
add_filter( 'wc_product_table_data_custom_field__regular_price, function( $price, $product ) { | |
return '€' . $price; | |
} ); |
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 | |
// Assuming you have cf:_sale_price as a column in your table... | |
add_filter( 'wc_product_table_data_custom_field__sale_price, function( $price, $product ) { | |
if ( empty( $price ) ) { | |
$price = get_post_meta( $product->get_id(), '_regular_price', true ); | |
} | |
return $price; | |
} ); |