Jump to content

cinolas

Members
  • Content count

    261
  • Joined

  • Last visited

  • Days Won

    2

cinolas last won the day on January 7 2017

cinolas had the most liked content!

Profile Information

  • Real Name
    Nicolas

Recent Profile Visitors

8,479 profile views
  1. cinolas

    Checkout when order total is $0

    Out of curiosity, so I can learn as I go, why would !is_object($$payment) == TRUE just because ["selected_module"]=> NULL? If I break down the IF in my original post and add custom debug messages, to see where it fails, like: if ( ($payment_modules->selected_module != $payment) ) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode('Not same as selected payment'), 'SSL')); } if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) ) ) { if ( !is_object($$payment)) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode('Is an array bigger than 1 AND $$payment is not an object'), 'SSL')); } else { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode('Is an array bigger than 1 but $$payment is an object'), 'SSL')); } } I get "Is an array bigger than 1 AND $$payment is not an object"
  2. cinolas

    Checkout when order total is $0

    That didn't do it, I still get: object(payment)#18 (2) { ["modules"]=> array(4) { [0]=> string(8) "free.php" [1]=> string(7) "cod.php" [2]=> string(16) "moneriscampg.php" [3]=> string(18) "paypal_express.php" } ["selected_module"]=> NULL } bool(true) NULL In fact I commented out the lines inside the first part of the IF and it didn't change anything, so I'm guessing that's not the problematic area after all. Thanks for trying though! I'm a bit weary of just editing code that's part of the checkout process without knowing exactly what it does, for fear that it may have deeper repercussions than just fixing my problem. But you guys keep me going. @Jack_mcs does the Git Voucher contrib empty the selected payment method for any reason? maybe it's doing it somewhere else during confirmation? Cheers to you two!
  3. cinolas

    Checkout when order total is $0

    Thanks @Jack_mcs, that sounds like a lot of work and I'm not sure it would be conclusive since I can't move everything to Frozen, and I don't understand quite enough to mix match both versions. Could the bit above, from the Gift Voucher contrib, be deselecting the payment module? Which I figure could be an unforeseen side-effect of mixing those two contribs. I'm not sure what check_credit_covers() does, so I'm not sure when $credit_covers is TRUE or not. But I'm thinking it checks to see if the credit balance "covers" the total of the invoice, and if so disables the payment module? Which would make sense if you're operating without the Free payment module that I'm trying to integrate, but in my scenario I think I want to keep the module selected? Searching blindly here, it may have nothing to do with my problem
  4. cinolas

    Checkout when order total is $0

    Thanks @ecartz, 'free' is the module code for the Free payment module I'm using as part of my install. It gets selected like a regular payment module. I've only made one change to it. I changed the update_status() so that it would only be available if there's enough Gift Voucher balance on that customer's account to pay for the entire order: if (tep_session_is_registered('customer_id')) { $gv_query = tep_db_query("select amount from coupon_gv_customer where customer_id = '" . tep_db_input($_SESSION['customer_id']) . "'"); $gv_result = tep_db_fetch_array($gv_query); } if ($order->info['total'] > $gv_result['amount']) { $this->enabled = false; } Re-reading this just now I got suspicious that the function may not work the second time, once the Gift Voucher has been applied and the total is $0. And it looked to me like it was being run from checkout_process.php, line 88, just before the problematic, but I commented out the disabling in the payment module and it gave me the same results, so I clearly don't understand what's happening. I'm not sure exactly where the $_SESSION['payment'] is normally set. I searched my code for bits that changed the selected_module, and of note is this part of /includes/classes/payment.php that deals with that and was changed by the Gift Voucher contrib. Everything else appears to be stock. // Begin Gift Vouchers Secure // check credit covers was setup to test whether credit covers is set in other parts of the code function check_credit_covers() { global $credit_covers; return $credit_covers; } function pre_confirmation_check() { global $credit_covers, $payment_modules; if (is_array($this->modules)) { if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { if ($credit_covers) { $GLOBALS[$this->selected_module]->enabled = false; $GLOBALS[$this->selected_module] = NULL; $payment_modules = ''; } else { $GLOBALS[$this->selected_module]->pre_confirmation_check(); } } } } // End Gift Vouchers Secure
  5. cinolas

    Checkout when order total is $0

    I get: object(payment)#18 (2) { ["modules"]=> array(4) { [0]=> string(8) "free.php" [1]=> string(7) "cod.php" [2]=> string(16) "moneriscampg.php" [3]=> string(18) "paypal_express.php" } ["selected_module"]=> NULL } bool(true) NULL
  6. cinolas

    Free Product Checkout Module (Bypass Payment)

    Thanks, @14steve14. I have set it to be the first payment module, but it looks like setting the correct number of other payment modules was just for when you want to bypass the payment page. I do need the payment page still, that's where the Gift Vouchers are applied. From the install instructions: Though even if you bypass both the payment and shipping pages, it's the confirmation page that refuses my order. I am not sure why. and not sure how to debug past that is_object($$payment) Thanks for the help!
  7. I'm using osC 2.34 BS GOLD and I'm customizing a Gift Voucher contrib along with a Free payment module. Everything is in place and working well but osC refuses to let me checkout when the order total = $0. I get to checkout_confirmation.php, click Confirm Order and I'm sent back to checkout_payment.php with the message: I'm told this is normal behaviour for osCommerce, and is part of core code that needs to be changed. But I also suspect that the Free payment module I'm using may be a bit outdated, and so may be missing something. Debugging this led me to line 90 of checkout_process.php where this IF sends me back to checkout_payment.php with the error: if ( ($payment_modules->selected_module != $payment) || ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL')); } Specifically this part returns TRUE: !is_object($$payment) The Free payment module I'm using has a code of "free". $payment = 'free' so $$payment = $free, and if I put a var_dump on checkout_confirmation.php I see: ["free"]=> object(free)#19 (5) { ["code"]=> string(4) "free" ["title"]=> string(36) "Pay with my Gift Certificate balance" ["description"]=> string(12) "Free Product" ["enabled"]=> bool(true) ["sort_order"]=> string(1) "1" } It looks like an object to me. But I admittedly don't know much about php objects... So why is !is_object($$payment) returning TRUE? Could the $$ nomenclature not be working? Is there a way to test that? Or maybe I'm going at this the wrong way? How can allow checkout when the total = $0? Any clues are greatly appreciated. Thanks!
  8. cinolas

    Gift Vouchers Secure

    Understood, I will. I just thought that part would be instrumental to the next version of this contrib working well with the Free payment module mod. But yeah, I get it. I'll post here when I have a solution. I did follow the link and read the threads, but none of them actually come up with an answer. The closest they get is with the same Free payment module, when used with a different coupon contrib that applies the coupon on the shopping cart page, so it's all about bypassing the payment page. I need the payment page because that's where the gift vouchers are applied Will post in General. Cheers!
  9. cinolas

    Gift Vouchers Secure

    SO CLOSE! Debugging this led me to line 90 of checkout_process.php where this IF sends me back to checkout_payment.php with the error: if ( ($payment_modules->selected_module != $payment) || ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL')); } Specifically this part returns TRUE: !is_object($$payment) $payment = 'free' so $$payment = $free, and if I put a var_dump on checkout_confirmation.php I see: ["free"]=> object(free)#19 (5) { ["code"]=> string(4) "free" ["title"]=> string(36) "Pay with my Gift Certificate balance" ["description"]=> string(12) "Free Product" ["enabled"]=> bool(true) ["sort_order"]=> string(1) "1" } It looks like an object to me. But I admittedly don't know much about php objects... I'll keep on kicking it until it works, I'm so close.
  10. cinolas

    Free Product Checkout Module (Bypass Payment)

    Specifically: is_object($$payment) Which is weird because $payment = 'free' and a var_dump on checkout_confirmation.php shows: ["free"]=> object(free)#19 (5) { ["code"]=> string(4) "free" ["title"]=> string(36) "Pay with my Gift Certificate balance" ["description"]=> string(12) "Free Product" ["enabled"]=> bool(true) ["sort_order"]=> string(1) "1" }
  11. cinolas

    Free Product Checkout Module (Bypass Payment)

    Oops I'm wrong, the first condition is TRUE. The problem appears to be with : is_object($$payment) && ($$payment->enabled == false) is_object($$payment) && ($$payment->enabled == false) Any ideas?
  12. cinolas

    Free Product Checkout Module (Bypass Payment)

    I'm trying to install this contribution on osC 2.3.4 BS GOLD, to be used with the Gift Voucher contribution: https://apps.oscommerce.com/KMILS&gift-vouchers-secure-v1-0 Everything is in place but when I get to checkout_confirmation.php and click the Confirm button, I get sent back to the checkout_payment.php with this error: "Please select a payment method for your order." The problem is caused by line 90 of checkout_process.php: if ( ($payment_modules->selected_module != $payment) || ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL')); } The first condition is false because $payment_modules->selected_module = NULL Why would it be false?
  13. cinolas

    Gift Vouchers Secure

    BUT it still won't let me checkout with an order total of $0 !!! DOH.... I guess I should've tested that Free payment module before doing all that... Sigh. two steps forward...
  14. cinolas

    Gift Vouchers Secure

    Ok, so it wasn't that difficult after all. I added an ID to the hidden checkbox. In the __construct() function of /includes/modules/order_total/ot_gv.php to this: function __construct() { global $order, $currencies; $this->code = 'ot_gv'; $this->title = MODULE_ORDER_TOTAL_GV_TITLE; $this->header = MODULE_ORDER_TOTAL_GV_HEADER; $this->description = MODULE_ORDER_TOTAL_GV_DESCRIPTION; $this->enabled = MODULE_ORDER_TOTAL_GV_STATUS; $this->sort_order = MODULE_ORDER_TOTAL_GV_SORT_ORDER; $this->include_shipping = MODULE_ORDER_TOTAL_GV_INC_SHIPPING; $this->include_tax = MODULE_ORDER_TOTAL_GV_INC_TAX; $this->calculate_tax = MODULE_ORDER_TOTAL_GV_CALC_TAX; $this->credit_tax = MODULE_ORDER_TOTAL_GV_CREDIT_TAX; $this->tax_class = MODULE_ORDER_TOTAL_GV_TAX_CLASS; $this->show_redeem_box = MODULE_ORDER_TOTAL_GV_REDEEM_BOX; $this->credit_class = true; // Added test to see if there's enough Gift Certificate balance to cover the entire order. If so, hide the Gift Certificate checkbox, if not hide the Free payment module and show the checkbox if (tep_session_is_registered('customer_id')) { $gv_query = tep_db_query("select amount from coupon_gv_customer where customer_id = '" . tep_db_input($_SESSION['customer_id']) . "'"); $gv_result = tep_db_fetch_array($gv_query); } If ($order->info['total'] > $gv_result['amount']) { $this->user_prompt = MODULE_ORDER_TOTAL_GV_USER_PROMPT; $this->checkbox = $this->user_prompt . ' (' . $currencies->format($gv_result['amount']) . ') <input type="checkbox" onClick="submitFunction()" id="GiftCertBox" name="' . 'c' . $this->code . '">'; } else { $this->user_prompt = ''; $this->checkbox = $this->user_prompt . '<input type="hidden" value="0" id="GiftCertBox "name="' . 'c' . $this->code . '">'; } $this->output = array(); } Then I modified the javascript_validation() function of /includes/classes/payment.php, line 76: function javascript_validation() { $js = ''; if (is_array($this->modules)) { $js = '<script><!-- ' . "\n" . 'function check_form() {' . "\n" . ' var error = 0;' . "\n" . ' var error_message = "' . JS_ERROR . '";' . "\n" . ' var payment_value = null;' . "\n" . ' var gc_box = document.getElementById("GiftCertBox");' . "\n" . ' if (document.checkout_payment.payment.length) {' . "\n" . ' for (var i=0; i<document.checkout_payment.payment.length; i++) {' . "\n" . ' if (document.checkout_payment.payment[i].checked) {' . "\n" . ' payment_value = document.checkout_payment.payment[i].value;' . "\n" . ' }' . "\n" . ' }' . "\n" . ' } else if (document.checkout_payment.payment.checked) {' . "\n" . ' payment_value = document.checkout_payment.payment.value;' . "\n" . ' } else if (document.checkout_payment.payment.value) {' . "\n" . ' payment_value = document.checkout_payment.payment.value;' . "\n" . ' }' . "\n\n"; reset($this->modules); while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); if ($GLOBALS[$class]->enabled) { $js .= $GLOBALS[$class]->javascript_validation(); } } //$js .= "\n" . ' if (payment_value == null) {' . "\n" . // ' error_message = error_message + "' . JS_ERROR_NO_PAYMENT_MODULE_SELECTED . '";' . "\n" . // ' error = 1;' . "\n" . // ' }' . "\n\n" . // ' if (error == 1) {' . "\n" . // ' alert(error_message);' . "\n" . // ' return false;' . "\n" . // ' } else {' . "\n" . // ' return true;' . "\n" . // ' }' . "\n" . // '}' . "\n" . // '//--></script>' . "\n"; // Begin Gift Vouchers Secure $js .= "\n" . ' if (payment_value == null && submitter != 1) {' . "\n" . ' error_message = error_message + "' . JS_ERROR_NO_PAYMENT_MODULE_SELECTED . '";' . "\n" . ' error = 1;' . "\n" . ' }' . "\n\n" . ' if (payment_value == "free") {' . "\n" . ' gc_box.value = 1;' . "\n" . ' }' . "\n\n" . ' if (error == 1 && submitter != 1) {' . "\n" . ' alert(error_message);' . "\n" . ' return false;' . "\n" . ' } else {' . "\n" . ' return true;' . "\n" . ' }' . "\n" . '}' . "\n" . '//--></script>' . "\n"; // End Gift Vouchers Secure Basically just adding: var gc_box = document.getElementById("GiftCertBox"); At the top, and at the bottom before the return: if (payment_value == "free") { gc_box.value = 1; } And that properly changes the value of the hidden checkbox! So on the checkout_confirmation.php page it shows Gift Voucher amount being removed, and the total is $0, and the selected payment method is the Free payment method as it all should be!
  15. Ok, so it wasn't that difficult after all. I added an ID to the hidden checkbox. In the __construct() function of /includes/modules/order_total/ot_gv.php to this: function __construct() { global $order, $currencies; $this->code = 'ot_gv'; $this->title = MODULE_ORDER_TOTAL_GV_TITLE; $this->header = MODULE_ORDER_TOTAL_GV_HEADER; $this->description = MODULE_ORDER_TOTAL_GV_DESCRIPTION; $this->enabled = MODULE_ORDER_TOTAL_GV_STATUS; $this->sort_order = MODULE_ORDER_TOTAL_GV_SORT_ORDER; $this->include_shipping = MODULE_ORDER_TOTAL_GV_INC_SHIPPING; $this->include_tax = MODULE_ORDER_TOTAL_GV_INC_TAX; $this->calculate_tax = MODULE_ORDER_TOTAL_GV_CALC_TAX; $this->credit_tax = MODULE_ORDER_TOTAL_GV_CREDIT_TAX; $this->tax_class = MODULE_ORDER_TOTAL_GV_TAX_CLASS; $this->show_redeem_box = MODULE_ORDER_TOTAL_GV_REDEEM_BOX; $this->credit_class = true; // Added test to see if there's enough Gift Certificate balance to cover the entire order. If so, hide the Gift Certificate checkbox, if not hide the Free payment module and show the checkbox if (tep_session_is_registered('customer_id')) { $gv_query = tep_db_query("select amount from coupon_gv_customer where customer_id = '" . tep_db_input($_SESSION['customer_id']) . "'"); $gv_result = tep_db_fetch_array($gv_query); } If ($order->info['total'] > $gv_result['amount']) { $this->user_prompt = MODULE_ORDER_TOTAL_GV_USER_PROMPT; $this->checkbox = $this->user_prompt . ' (' . $currencies->format($gv_result['amount']) . ') <input type="checkbox" onClick="submitFunction()" id="GiftCertBox" name="' . 'c' . $this->code . '">'; } else { $this->user_prompt = ''; $this->checkbox = $this->user_prompt . '<input type="hidden" value="0" id="GiftCertBox "name="' . 'c' . $this->code . '">'; } $this->output = array(); } Then I modified the javascript_validation() function of /includes/classes/payment.php, line 76: function javascript_validation() { $js = ''; if (is_array($this->modules)) { $js = '<script><!-- ' . "\n" . 'function check_form() {' . "\n" . ' var error = 0;' . "\n" . ' var error_message = "' . JS_ERROR . '";' . "\n" . ' var payment_value = null;' . "\n" . ' var gc_box = document.getElementById("GiftCertBox");' . "\n" . ' if (document.checkout_payment.payment.length) {' . "\n" . ' for (var i=0; i<document.checkout_payment.payment.length; i++) {' . "\n" . ' if (document.checkout_payment.payment[i].checked) {' . "\n" . ' payment_value = document.checkout_payment.payment[i].value;' . "\n" . ' }' . "\n" . ' }' . "\n" . ' } else if (document.checkout_payment.payment.checked) {' . "\n" . ' payment_value = document.checkout_payment.payment.value;' . "\n" . ' } else if (document.checkout_payment.payment.value) {' . "\n" . ' payment_value = document.checkout_payment.payment.value;' . "\n" . ' }' . "\n\n"; reset($this->modules); while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); if ($GLOBALS[$class]->enabled) { $js .= $GLOBALS[$class]->javascript_validation(); } } //$js .= "\n" . ' if (payment_value == null) {' . "\n" . // ' error_message = error_message + "' . JS_ERROR_NO_PAYMENT_MODULE_SELECTED . '";' . "\n" . // ' error = 1;' . "\n" . // ' }' . "\n\n" . // ' if (error == 1) {' . "\n" . // ' alert(error_message);' . "\n" . // ' return false;' . "\n" . // ' } else {' . "\n" . // ' return true;' . "\n" . // ' }' . "\n" . // '}' . "\n" . // '//--></script>' . "\n"; // Begin Gift Vouchers Secure $js .= "\n" . ' if (payment_value == null && submitter != 1) {' . "\n" . ' error_message = error_message + "' . JS_ERROR_NO_PAYMENT_MODULE_SELECTED . '";' . "\n" . ' error = 1;' . "\n" . ' }' . "\n\n" . ' if (payment_value == "free") {' . "\n" . ' gc_box.value = 1;' . "\n" . ' }' . "\n\n" . ' if (error == 1 && submitter != 1) {' . "\n" . ' alert(error_message);' . "\n" . ' return false;' . "\n" . ' } else {' . "\n" . ' return true;' . "\n" . ' }' . "\n" . '}' . "\n" . '//--></script>' . "\n"; // End Gift Vouchers Secure Basically just adding: var gc_box = document.getElementById("GiftCertBox"); At the top, and at the bottom before the return: if (payment_value == "free") { gc_box.value = 1; } And that properly changes the value of the hidden checkbox, and does what I need it to! Unfortunately, osC stil won't let me checkout with an order total = $0 but that's another story.
×