Skip to content

Instantly share code, notes, and snippets.

@GauravKhupse
Created August 25, 2021 10:16
Show Gist options
  • Save GauravKhupse/9d7588b9d8e8166183e18dc1d2891e2c to your computer and use it in GitHub Desktop.
Save GauravKhupse/9d7588b9d8e8166183e18dc1d2891e2c to your computer and use it in GitHub Desktop.
Fixed Backorder instead of On backorder with Woo Commerce fetch availability
add_filter( 'wp_schema_pro_schema_product', 'my_extra_schema_field_mapping', 10, 3 );
/**
* Mapping extra field for schema markup.
*
* @param array $schema Schema array.
* @param array $data Mapping fields array.
* @return array
*/
function my_extra_schema_field_mapping( $schema, $data, $post ) {
if ( isset( $data['avail'] ) && ! empty( $data['avail'] ) ) {
if('onbackorder' === $data['avail']) {
$schema['offers']['availability'] = "BackOrder";
}
}
return $schema;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment