Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Porting 2.2 addon - Minimum Product Quantity - to 2.3


oxwivi

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.

Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
Share on other sites

  • 1 year later...

@@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

Link to comment
Share on other sites

  • 1 year later...

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...