Created
August 25, 2021 10:16
-
-
Save GauravKhupse/9d7588b9d8e8166183e18dc1d2891e2c to your computer and use it in GitHub Desktop.
Fixed Backorder instead of On backorder with Woo Commerce fetch availability
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
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