Last active
April 24, 2023 13:45
-
-
Save Auke1810/031020a6836cbab0836cb7d6bcea5007 to your computer and use it in GitHub Desktop.
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
<?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