Advance software forum
May 18, 2012, 07:52:32 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Ajax CheckOut Contribution - Stock check bug - RESOLVED  (Read 722 times)
0 Members and 1 Guest are viewing this topic.
b_vassy
Newbie
*
Offline Offline

Posts: 1


View Profile
« on: December 24, 2008, 06:33:48 PM »

Hi there,

First of all, thank you for this great contribution.

But I found a bug in the Ajax CheckOut Contribution. If in oscommerce Admin you have "Check stock level" set to "true", even if you have "Allow Checkout" set to "true", the script won't let you place the order. The right thing to do would be to check the stock level and if "Allow Checkout" is set to "true" to let you place the order but warn you that the product is out of stock.

My solution is this:

In "catalog\ajax\classes\ajaxManagerTest.class.php", arround line 1235, find:

Code:
    // Stock Check
      $any_out_of_stock = false;
      if (STOCK_CHECK == 'true') {
        for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
          if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
            $any_out_of_stock = true;
          }
        }
      }
      if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) $any_out_of_stock == true;
      else $any_out_of_stock == false;
   
  if (
    ajaxSessionIsRegistered('sendto') &&
    ajaxSessionIsRegistered('billto') &&
    ajaxSessionIsRegistered('shipping') &&
    ajaxSessionIsRegistered('payment') &&
    ajaxSessionIsRegistered('customer_id') &&
    is_object($payment_class) &&
    is_array($shipping) && $any_out_of_stock == false
    )
   
    {

      if (isset($payment_class->form_action_url)) {
     
          $form_action_url = $payment_class->form_action_url;
          echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');
          echo $payment_class->process_button();
          echo '<input type="submit" value="Place Order"></form>';
     
      } else {
        echo '<input type="button" value="Place Order" onClick="ajaxPerformPlaceOrder();" id="buttonPlaceOrder">';
      }
    }
    else
    {

        if ($any_out_of_stock == true) {

          require_once(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);
       
          if (STOCK_ALLOW_CHECKOUT == 'true') {
    ?>    <table width=100% border=0>
          <tr>
            <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CAN_CHECKOUT?></td>
          </tr>
          </table>
    <?php
          
} else {
    
?>
    <table width=100% border=0>
          <tr>
            <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT?></td>
          </tr>
          </table>
    <?php
          
}
        }
    
    }

and replace with:

Code:
    // Stock Check
      $any_out_of_stock = false;
      if (STOCK_CHECK == 'true') {
        for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
          if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
            $any_out_of_stock = true;
          }
        }
      }
   
  if (
    ajaxSessionIsRegistered('sendto') &&
    ajaxSessionIsRegistered('billto') &&
    ajaxSessionIsRegistered('shipping') &&
    ajaxSessionIsRegistered('payment') &&
    ajaxSessionIsRegistered('customer_id') &&
    is_object($payment_class) &&
    is_array($shipping) )
   
    {
if ( ($any_out_of_stock == false) || ( ($any_out_of_stock == true) && (STOCK_ALLOW_CHECKOUT == 'true') ) ) {
if (isset($payment_class->form_action_url)) {
$form_action_url = $payment_class->form_action_url;
echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');
echo $payment_class->process_button();
echo '<input type="submit" value="Place Order"></form>';
      } else {
echo '<input type="button" value="Place Order" onClick="ajaxPerformPlaceOrder();" id="buttonPlaceOrder">';
      }

if ($any_out_of_stock == true) {
require_once(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);

?><table width=100% border=0>
    <tr>
<td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CAN_CHECKOUT?></td>
    </tr>
    </table><?php
}
}

else {
?>
<table width=100% border=0>
          <tr>
            <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT?></td>
          </tr>
          </table>
    <?php
}
    }

If you have other questions, please let me know.

Best regards,
Vassy
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 3.1.1 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!