Jump to content
Sign in to follow this  
oxwivi

Porting 2.2 addon - Minimum Product Quantity - to 2.3

Recommended Posts

I started using osC with 2.3.1 and require the usage of this addon, Minimum Product Quantity with Admin, made for osC 2.2. Downloading the addons gives only a text file with the codes and instructions to add to osC - I've made it available on Pastebin.com.

 

Since I don't know how the structure of osC have changed since 2.2, I've no idea how to go about it. Please guide me.

Share this post


Link to post
Share on other sites

I'm successfully using this on a stock osC 2.3.1 installation. With a few minor changes in the code to conform with the 2.3 install it worked like a charm. If anyone is interested in releasing the addon as 2.3 compatible, please feel free to contact me.

 

Additionally, I would like to request a bit of help from the more coding-friendly osC brethren to refine a feature of this addon. Currently this piece of code takes care of changing the quantity to the minimum specified at the shopping cart:

 

//Minimum quantity code
if(MINIMUM_ORDERS == 'true'){
  $min_order_query = tep_db_query("select p.minorder as min_quant FROM " . TABLE_PRODUCTS . " p where p.products_id = '".$products[$i]['id']."'");
while ($min_order = tep_db_fetch_array($min_order_query))  {
  if ($products[$i]['quantity'] < $min_order['min_quant'] ) {
  $products[$i]['min_quant']=$min_order['min_quant'];
  }
}
 if ($products[$i]['quantity'] < $products[$i]['min_quant'] ) {
  $products[$i]['quantity']=$products[$i]['min_quant'];
 $cart->add_cart($products[$i]['id'],$products[$i]['quantity'],$products[$i]['attributes']);
 $cart_notice = sprintf(MINIMUM_ORDER_NOTICE, $products[$i]["name"], $products[$i]["min_quant"]);
}
}
//End Minimum quantity code

 

The thing is, only the warning appears that it's below the MOQ and that it's changing it to the minimum quantity. But the quantity boxes does not reflect the change until the page is refreshed or the user navigates away and returns to the cart. How do I make it so the quantity boxes are immediately updated?

Edited by oxwivi

Share this post


Link to post
Share on other sites

@@oxwivi can you possibly tell me what code you need to change to get this to work on 2.3.1? please as i need this for my store to work but cannot get it to work and its driving me crazy!! i think the problem lies in step 13,14,15 where it tells me to update lines that dont exist on my index page? many thanks

Share this post


Link to post
Share on other sites

After hours of trying to figure it out, changing the code, and changing the code again and again tried something else.  It worked.
 
All of this is on 2.3.4 now - moved from 2.2RC2a
 
The only thing that would not work was shopping cart.  It would display warning but not update quantity.
 
Just move the code up and it works fine.
 
   //Minimum quantity code
    if(MINIMUM_ORDERS == 'true'){
      $min_order_query = tep_db_query("select p.minorder as min_quant FROM " . TABLE_PRODUCTS . " p where p.products_id = '".$products[$i]['id']."'");
    while ($min_order = tep_db_fetch_array($min_order_query))  {
      if ($products[$i]['quantity'] < $min_order['min_quant'] ) {
            $products[$i]['min_quant']=$min_order['min_quant'];
      }
    }

     if ($products[$i]['quantity'] < $products[$i]['min_quant'] ) {
         $products[$i]['quantity']=$products[$i]['min_quant'];
        $cart->update_quantity($products[$i]['id'],$products[$i]['quantity'],$products[$i]['attributes']);
        $cart_notice = sprintf(MINIMUM_ORDER_NOTICE, $products[$i]["name"], $products[$i]["min_quant"]);
    }
    }
    //End Minimum quantity code
       $products_name .= '<br /><br />' . tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']) . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . '   ' . TEXT_OR . '<a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">' . TEXT_REMOVE . '</a>';

      $products_name .= '    </td>' .
                        '  </tr>' .
                        '</table>';

// THIS IS WHERE MINIMUM QUANTITY CODE WAS ON 2.2 AND ALL I DID WAS MOVE IT UP ABOVE THE PRODUCTS_NAME SECTION ABOVE AND IT STARTED WORKING FINE.  EVEN UPDATING THE QUANTITY TO 1 CHANGED IT BACK TO MINIMUM QTY

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×