-
Notifications
You must be signed in to change notification settings - Fork 27
/
pmxe_woo_field.php
40 lines (34 loc) · 970 Bytes
/
pmxe_woo_field.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* ==================================
* Filter: pmxe_woo_field
* ==================================
*
* Filters WooCommerce fields.
*
*
* @param $value - The value of the field.
* @param $field_name - The field name.
* @param $pid - The post ID.
*
* @return string
*/
add_filter( 'pmxe_woo_field', 'wp_all_export_woo_field', 10, 3 );
function wp_all_export_woo_field( $value, $field_name, $pid ) {
// Code here.
}
// ----------------------------
// Example uses below
// ----------------------------
/**
* Change crossell and upsell fields to product IDs instead of SKUs.
*
*/
add_filter('pmxe_woo_field', 'wp_all_export_woo_field', 10, 3);
function wp_all_export_woo_field( $value, $field_name, $pid ) {
if ( $field_name == '_crosssell_ids' || $field_name == '_upsell_ids' ) {
$_ids = maybe_unserialize( get_post_meta( $pid, $field_name, true ) );
$value = empty( $_ids ) ? '' : implode( "|", $_ids );
}
return $value;
}