WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce Payment Gateway - Inspire
[resolved] Hide Payment gateway based on zip code (3 posts)

  1. mlbadvertising
    Member
    Posted 1 year ago #

    Hi,

    I'm having some difficulty implementing a custom design with the inspire commerce plugin. My store has two payment options: Local pickup and Payment with credit card (Via inspire commerce). Because of the nature of this store, we cannot ship to certain zip codes outside of an effective range; this would effectively limit their shipping choices to "Local pickup" only. Because of this, our client has stated they'd like such people to be able to pay on pickup only. This means they cannot pay via credit card and the inspire commerce "Pay with credit card" option must be denied based on their zip code. I attempted making my own function for my theme's functions.php file using code I've found here: http://wordpress.org/support/topic/restrict-payment-options-based-on-product

    function filter_gateways($gateways){
    global $order;
    foreach ($order -> shipping_zip as $key => $values ) {
    if ($values < 18000 || $values > 20000) {
    $values = false;
    }
    else {
    $values = true;
    }
    if($values == false){
    unset($gateways['inspire']);
    break;
    }}
    return $gateways;
    }

    I'm certain I've messed something up, most specifically with ($order -> shipping_zip). If any help or documentation can be provided that could help me out, I'd greatly appreciate it.

    EDIT: Alternatively, I suppose this can be based off "shipping Method" instead of "Shipping zip code" (As there is already a rule in place to restrict shipping method based on zip code).

    In other words (Pseudocode):

    IF Local Pickup {
    unset inspire commerce
    }

  2. inspire
    Member
    Plugin Author

    Posted 1 year ago #

    @mlbadvertising , great question. Unfortunately the scope of the question is outside of our support forum here because you're asking about WooCommerce core logic, and not our gateway plugin logic. I have several ideas for you to get the exact support you need for this. Either email support @ inspirecommerce.com or call our office. Ask for Mark.

  3. mlbadvertising
    Member
    Posted 1 year ago #

    You're absolutely right about the nature of this question, I just wasn't sure if there was a better place to ask this. Thank you for the response. I'll follow up on this using one of the two methods.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic