Support » Plugin: Afterpay Gateway for WooCommerce » Exclude Afterpay from backorders

  • btbau

    (@btbau)


    How can I keep afterpay from showing up on products available on backorder?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Afterpay

    (@afterpayit)

    Hi @btbau,

    Thanks for your question.

    The Afterpay plugin currently does not support hiding the message for selective products. However, the following code snippet can help to keep consumers from buying backorder products using Afterpay. It would still show a message though. I.e. “Afterpay is not available for purchasing this item”.

    function afterpay_ips_callback( $bool_result, $product ) {
         if ($product->backorders_allowed()) {
             $bool_result = false;
         }
         return $bool_result;
     }
     add_filter( 'afterpay_is_product_supported', 'afterpay_ips_callback', 10, 2 );

    Thank you.

    Thread Starter btbau

    (@btbau)

    Where do I put that code snippet?

    I have Afterpay enabled on Individual product pages and the checkout, does that code snippet get added to those respective code boxes in the plugin?

    So in the snippet box for Individual products it would look like this?

    data-show-upper-limit="true" data-show-lower-limit="true" data-logo-type="badge" data-badge-theme="black-on-mint" data-size="md" data-modal-theme="mint"
    
    function afterpay_ips_callback( $bool_result, $product ) {
         if ($product->backorders_allowed()) {
             $bool_result = false;
         }
         return $bool_result;
     }
     add_filter( 'afterpay_is_product_supported', 'afterpay_ips_callback', 10, 2 );
    • This reply was modified 6 months ago by btbau.
    Plugin Author Afterpay

    (@afterpayit)

    Hi @btbau,

    Thanks for your question.

    The code snippet is usually pasted into the functions.php file of the active theme. Please be mindful that it may need to be pasted again if the theme gets updated.

    This is something that is recommended for the site development partner to action. As always with these types of changes a full site backup (database and files) before commencing is strongly recommended.

    Thank you.

    Thread Starter btbau

    (@btbau)

    Is Afterpay working on implementing an update that will allow products to be filtered out by stock level, changes to PHP that need to be repaired after update is really kind of average.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude Afterpay from backorders’ is closed to new replies.