Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Create a workaround class for backward compatibility
- */
- if ( ! function_exists( 'WPAS' ) ) {
- class WPAS_Workaround {
- public $products_sync;
- }
- function WPAS() {
- return new WPAS_Workaround();
- }
- }
- add_filter( 'wpas_hierarchical_taxonomy_dropdown_options_label', 'wpas_custom_product_label', 10, 3 );
- /**
- * Add SKU after product name in the products dropdown
- *
- * @param string $label The option label
- * @param WP_Term $term The term object
- * @param mixed $value Option value if any set
- *
- * @return string
- */
- function wpas_custom_product_label( $label, $term, $value ) {
- global $wpas_product_sync;
- if ( 'product' !== $term->taxonomy ) {
- return $label;
- }
- $is_sync = WPAS()->products_sync->is_synced_term( $term->term_id );
- if ( false === $is_sync ) {
- return $label;
- }
- $sku = get_post_meta( $is_sync, '_sku', true );
- $label = "$label - $sku";
- return $label;
- }
Advertisement
Add Comment
Please, Sign In to add comment