• I am editing my original review because the support received through the folks here has been excellent. I must say the assistance offered has been very rapid and helpful to say the least. Although support through the website is less than helpful, I cannot say that for the team here.

    In the future I will use the support forum for support – It certainly wasn’t my intention to use a bad review to get support however the team responded positively.

    Original Review Below:
    Support is very poor! Trying to just exclude a category (which I am sure many woocommerce users will need to do at some time)

    The hook provided in the developer docs only excludes “product types” not categories an email asking for support got the “canned response” this is outside the support offered by Afterpay.

    All I wanted was some direction or a guide of how to achieve this.

    • This topic was modified 4 years, 3 months ago by Gary. Reason: Support via this group has been excellent
    • This topic was modified 4 years, 3 months ago by Gary.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Afterpay

    (@afterpayit)

    Hi @zulu11,

    Thank you for your honest review of the plugin. The engineering team here on www.remarpro.com (the authors of the plugin) are more than happy to assist with this challenge.

    The afterpay_is_product_supported hook (documented here) can be leveraged to achieve the outcome described above. If a callback function is attached to this Filter with two arguments, the second will be populated with a WC_Product object. This object exposes a method called get_category_ids, which can be used to exclude Afterpay from a given list of Product Categories.

    For example:

    /**
     * @param bool      $bool_result
     * @param WC_Product    $product
     */
    function afterpay_ips_callback( $bool_result, $product ) {
        # Categories #1 and #3 don't support Afterpay.
        if (array_intersect( $product->get_category_ids(), array(1, 3) ) {
            $bool_result = false;
        }
        return $bool_result;
    }
    add_filter( 'afterpay_is_product_supported', 'afterpay_ips_callback', 10, 2 );

    Please try to implement something similar to the above inside the active theme’s functions.php file, replacing the category IDs as needed. Don’t hesitate to reply back to this thread if further support is needed.

    Thank you.

    Thread Starter Gary

    (@zulu11)

    Hi Thanks for your prompt response! Much appreciated.

    I have made changes to the category ids and tried this in the functions file but I am getting a syntax error – syntax error is -> unexpected “;” after the line:

    $bool_result=false;

    I have tried making some other small changes to the code to find the problem but I have had no luck, do you have any other suggestions?

    Many thanks.

    Plugin Author Afterpay

    (@afterpayit)

    Hi Gary,

    You are correct, there is a syntax error in the code provided above. The line before the line with $bool_result=false; is missing a closing parenthesis. It should read as follows:

        if (array_intersect( $product->get_category_ids(), array(1, 3) )) {
    

    Please excuse the mistake. Let us know how you go with the amendment above.

    Thank you.

    Thread Starter Gary

    (@zulu11)

    Hi Thanks very much that worked perfectly! It is now not offering the Afterpay on my selected categories – however I am still able to use Afterpay at the checkout. Is there a way to prevent this?

    Plugin Author Afterpay

    (@afterpayit)

    Hi Gary,

    Great to hear that the solution is operating as intended for most pages. The expectation is that Afterpay would also be unavailable at the checkout if one or more products in the cart are identified as unsupported using this method.

    Please leave this with the team to investigate further on your behalf. Will reply back here within 2 business days.

    Thank you also for updating your rating!

    Plugin Author Afterpay

    (@afterpayit)

    Hi @zulu11,

    Here is a temporary solution to remove it from the available payment methods. Please copy the following snippet to the function.php in the active theme and replace the category IDs as needed.

    /**
     * @param array      $gateways
     */
    function afterpay_apg_callback( $gateways ) {
        foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
            $product = $cart_item['data'];
            # Categories #1 and #3 don't support Afterpay.
    	if (array_intersect( $product->get_category_ids(), array(1, 3) )) {
    	    unset($gateways['afterpay']);
    	    break;
    	}
        }
        return $gateways;
    }
    add_filter( 'woocommerce_available_payment_gateways', 'afterpay_apg_callback', 10, 2);

    The engineering team will also include a similar enhancement in the next release.

    Thank you.

    • This reply was modified 4 years, 3 months ago by Afterpay.
    Thread Starter Gary

    (@zulu11)

    Thank you so much for your help with this. It works perfectly now, I appreciate the time you took to help me with a solution!

    Plugin Author Afterpay

    (@afterpayit)

    Hi Gary,

    More than happy to help. Glad it’s all working now.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Excellent Support Via The Support Forum’ is closed to new replies.