Plugin Directory

Changeset 1748006


Ignore:
Timestamp:
10/17/2017 02:36:13 PM (8 years ago)
Author:
nickvdberg
Message:

Fix coupon check

File:
1 edited

Legend:

Unmodified
Added
Removed
  • woo-ea/tags/1.0.2/earnbox-for-woocommerce.php

    r1747812 r1748006  
    534534
    535535function wc_earnbox_email_instructions( $order, $sent_to_admin ) {
     536    $earnboxSettings = WC_Admin_Settings::get_option( 'woocommerce_earnbox_settings' );
     537    $earnbox_enabled = $earnboxSettings['enabled'];
     538    if ($earnbox_enabled == "no") return;
    536539
    537540    // If EarnBox coupon was used, don't generate cashback.
    538541    foreach( $order->get_used_coupons() as $coupon) {
    539     if ($coupon == "earnbox discount") {
     542        $coupon_used = strrpos($coupon, "earnbox discount");
     543        if ($coupon_used == 0 || $coupon_used != false) {
    540544            return false;
    541545        }
     
    543547
    544548  if ( ! $sent_to_admin && $order->get_status() == 'completed' && $order->get_payment_method() != "earnbox" && $order->get_payment_method() != "cod" ) {
     549        error_log("Generate cashback", 0);
    545550        echo "<h3>Claim Your Cashback:</h3>";
    546         $earnboxSettings = WC_Admin_Settings::get_option( 'woocommerce_earnbox_settings' );
     551
    547552        array_shift($earnboxSettings);
    548553        $secret = $earnboxSettings['secret'];
Note: See TracChangeset for help on using the changeset viewer.