Skip to content

Instantly share code, notes, and snippets.

@Auke1810
Last active April 24, 2023 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Auke1810/031020a6836cbab0836cb7d6bcea5007 to your computer and use it in GitHub Desktop.
Save Auke1810/031020a6836cbab0836cb7d6bcea5007 to your computer and use it in GitHub Desktop.
<?php
function add_availability_date_when_backorder( $attributes, $feed_id, $product_id ) {
$wc_product = wc_get_product( $product_id ); // Get the WC_Product Object
if ($wc_product->is_on_backorder() ) {
// add availability_date attribute
$attributes['availability_date'] = gmdate( 'c', strtotime( '+7 days' ) );
}
// IMPORTANT! Always return the $attributes
return $attributes;
}
add_filter( 'wppfm_feed_item_value', 'add_availability_date_when_backorder', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment