Results 1 to 3 of 3
  1. #1
    Join Date
    May 2008
    Location
    United States
    Posts
    490
    Plugin Contributions
    1

    Default Restrict coupon code on PO Box shipping addresses

    I'm trying to restrict a coupon code that gives free shipping to PO Box shipping addresses. I ship with three carriers UPS, FedEx, and USPS. I customized UPS and FedEx shipping modules to disable using the following statement:

    PHP Code:
          if ( preg_match('/PO BOX/si'$order->delivery['street_address'])) { 
                    
    $this->enabled false;
            
    $po_box_address true;
          } else if ( 
    preg_match('/POBOX/si'$order->delivery['street_address'])) { 
                    
    $this->enabled false;
            
    $po_box_address true;
          } else if ( 
    preg_match('/P\.O\./si'$order->delivery['street_address'])) { 
                    
    $this->enabled false;
            
    $po_box_address true;
          } else if ( 
    preg_match('/P\.O/si'$order->delivery['street_address'])) { 
                    
    $this->enabled false;
            
    $po_box_address true;
          } else if ( 
    preg_match('/PO\./si'$order->delivery['street_address'])) { 
                    
    $this->enabled false;
            
    $po_box_address true;
          } 
    That part works perfect and forces PO Box shipping address to have only USPS as a selection. Now I need to restrict a certain coupon code: "XXXXX" from being used for free shipping on PO Box shipping addresses only. ** A billing address can be a PO Box just not the shipping address.

    I was thinking either ot_coupon.php file or coupon_restrict.php needs to be modified for this just not sure how to properly do it. Can anyone help on this?

  2. #2
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,915
    Plugin Contributions
    13

    Default Re: Restrict coupon code on PO Box shipping addresses

    this will definitely be in the ot_coupon.php and more specifically in the collect_posts function.

    based on your code something like this may work:

    PHP Code:
          $po_box_address false;
          if ( 
    preg_match('/PO BOX/si'$order->delivery['street_address'])) { 
            
    $po_box_address true;
          } else if ( 
    preg_match('/POBOX/si'$order->delivery['street_address'])) { 
            
    $po_box_address true;
          } else if ( 
    preg_match('/P\.O\./si'$order->delivery['street_address'])) { 
            
    $po_box_address true;
          } else if ( 
    preg_match('/P\.O/si'$order->delivery['street_address'])) { 
            
    $po_box_address true;
          } else if ( 
    preg_match('/PO\./si'$order->delivery['street_address'])) { 
            
    $po_box_address true;
          }        
          if (
    $po_box_address) {
            
    $messageStack->add_session('redemptions'PO_BOX_WARNING'caution');
            
    $this->clear_posts();
            
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL',truefalse));
          } 
    no guarantees.... also i would separate out the check PO box into a separate function and then call that function from both places. in my experience, PO BOX customers will do anything to get around the restrictions associated with their address. better to maintain the code in one place than in two.

    good luck!
    author of square Webpay.
    mxWorks now has Apple Pay and Google Pay. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  3. #3
    Join Date
    May 2008
    Location
    United States
    Posts
    490
    Plugin Contributions
    1

    Default Re: Restrict coupon code on PO Box shipping addresses

    it worked thank you!

 

 

Similar Threads

  1. Replies: 2
    Last Post: 14 Mar 2014, 07:06 PM
  2. PayPal Express Coupon Discount Promo Code Box
    By jasmel in forum PayPal Express Checkout support
    Replies: 9
    Last Post: 14 Aug 2013, 02:50 PM
  3. Hiding the coupon code box?
    By kinkyropes in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 4
    Last Post: 12 Oct 2008, 10:41 PM
  4. Hiding the coupon code box...
    By aaelghat in forum General Questions
    Replies: 3
    Last Post: 22 Sep 2008, 06:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg