Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Bootstrap Quantity Box


Recommended Posts

@@greasemonkey  Hi Scott....at this point it is still a work in progress....well sort of....I really haven't been working on it though.   I decided, in the grand scheme of things, I was spending way too much time on it and should probably focus on some other things so it went on the back burner...hopefully I'll get back to it before you need it and if so I'll be sure to post it here.  With the code that you and Lambros contributed it worked fine...I just couldn't quite get the look I was after.

 

Dan

Link to comment
Share on other sites

  • Replies 62
  • Created
  • Last Reply

@@greasemonkey

 

disregard my previous post, that was bullshit.

 

Try this once

$prod_list_contents .= ' <div class="btn-wrap">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id'], 'SSL'), 'POST') . tep_draw_input_field('buyqty', '1', 'size="3" style="vertical-align:middle') .' '. tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', NULL, NULL, 'btn-success btn-sm') . '</form>';
Link to comment
Share on other sites

@@Dan Cole thanks Dan... My code does "work".... But throws warning under https.

 

@greasemonkey

 

what error message do you get? the unsecured item bla, bla, bla message?

does your shop redirect top the shopping cart when you add items?

does it work with the stock osC button without the plus/minus?

do you have any unsecured link inside the footer or header? facebook or twitter link?

 

I had also an SSL issue just 2-3 days back (osC 2.3.3.4), burt and whitehat helped me out and it was an issue with unsecured external links and wrong redirect to the cart and index.php

I must admit though I am not very familiar with osC 2.3.4 BS and SSL yet, still working on my own osC 2.3.4 BS shop myself.

Link to comment
Share on other sites

@@Tsimi thank you very kindly!!!! I was trying this earlier, but must have been putting the SSL in the wrong place.

 

 

Try this once

$prod_list_contents .= ' <div class="btn-wrap">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id'], 'SSL'), 'POST') . tep_draw_input_field('buyqty', '1', 'size="3" style="vertical-align:middle') .' '. tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', NULL, NULL, 'btn-success btn-sm') . '</form>';

 

I have this working - with a slight change.... from 'SSL' to $request_type - so it works with both https & http (SSL & non-SSL).

">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id'], $request_type), 'POST') . tep_draw_input_field('buyqty', '1', 'size="3" style="vertical-align:middle') .' '. tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', NULL, NULL, 'btn-success btn-sm') . '</form>';

I'll let you know if anything comes up.

 

To answer your other questions

 

what error message do you get? the unsecured item bla, bla, bla message?

does your shop redirect top the shopping cart when you add items?

does it work with the stock osC button without the plus/minus?

do you have any unsecured link inside the footer or header? facebook or twitter link?

Yes - "unsecure bla, bla bla...."

No - I don't redirect to shopping cart

Not there yet... this is just a qty box in product listing... no jquery plus minus button yet.

No - no other unsecure warnings.

 

So, it seems to be fixed (at least in testing)...... But as I said. I'll post if anything else comes up.

 

I'll also start to work on the jquery buttons from the code you guys posted earlier to see if I can adapt to the product listing and product info.

Link to comment
Share on other sites

@@Tsimi have you by chance looked at this in 2.3.4 BS Gold?

 

Having multiple issues here. Can get the button to add the multiple items - it seems to be ignoring

if($HTTP_POST_VARS['buyqty']=="") {

in application_top.php

 

And I can't get the button to style with btn-success btn-sm (its grabing btn btn-default from somewhere)????

$prod_list_contents .= '       <div class="col-xs-6 text-right">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id']), 'POST') . tep_draw_input_field('buyqty', '1', 'size="3" style="vertical-align:middle') .' '. tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', NULL, NULL, 'btn-success btn-sm') . '</div></form>';
	
Link to comment
Share on other sites

@@greasemonkey

 

Can you please try this once

$prod_list_contents .= ' <div class="col-xs-6 text-right">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id']), 'POST') . tep_draw_input_field('buyqty', '1', 'style="width:60px;text-align:center;"') . ' ' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', NULL, NULL, NULL, 'btn-success btn-sm') . '</form></div>';
Link to comment
Share on other sites

Not much further ahead... So far as I can tell it should work.

 

The functions in html_output for draw_form and input_field haven't changed... and the buy_now and buyqty changes in application top should work...

 

The change I see, when I look at the source url for the buttons pre and post GOLD are below.

 

Pre Gold;

<div class="btn-wrap"><form name="buy_now" action="http://www.mysite.com/modeling-chocolate-c-24.html?action=buy_now&products_id=12&sort=2a" method="POST"><input type="text" name="buyqty" value="1" size="3" style="vertical-align:middle class="form-control" /> <button type="s" s class="btn btn-default"> <span class="glyphicon cart"></span> Buy Now</button></form> </div><!--btn-wrap--> 

and now in gold

<div class="col-xs-6 text-right"><form name="buy_now" action="http://www.mysite.com/sandbox4/index.php?cPath=3_10&sort=2a&action=buy_now&products_id=12" method="POST"><input type="text" name="buyqty" value="1" style="width:60px;text-align:center;" class="form-control" /> <button  type="submit" class="btn btn-success btn-sm"> <span class="cart"></span> Buy Now</button></form></div>

The only difference are in the "input type" and SEO URL's.... On the off chance this is "helping" the pre-gold post the variable from the quantity box I will install it to check.

Link to comment
Share on other sites

Here is the working application_top and product listing code - ignore all previous attempts.

 

I've also added $request_type for SSL and input type 'number' or 'tel' for mobile. Please let me know if you see any issues.

 

Application_top is

// performed by the 'buy now' button in product listings and review page
       case 'buy_now' : if (isset($HTTP_GET_VARS['products_id'])) {
                            if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
                            tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
                            } else {
                        //modification by Alexander Dimelow (www.web-project.co.uk)
                              if($HTTP_POST_VARS['buyqty']=="") {
                               $quantity = 1;
                                }else{
                               $quantity = $HTTP_POST_VARS['buyqty']; 
                               }
                        //end of modification by Alexander Dimelow (www.web-project.co.uk)
                            $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+$quantity);
							$messageStack->add_session('product_action', sprintf(PRODUCT_ADDED, tep_get_products_name((int)$HTTP_GET_VARS['products_id'])), 'success');
                                }
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;

And product listing is

     $prod_list_contents .= '        <div class="col-xs-6 text-right">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id'], $request_type), 'POST') . tep_draw_input_field('buyqty', '1', 'style="width:40px;text-align:center;"', 'tel') . ' ' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', NULL, NULL, NULL, 'btn-success btn-sm') . '</form></div>';

I've chosen to make the box slightly small (40px) and also use 'tel' input type instead of 'number' - 'number' requires a larger box (60px) and also leaves up & down arrows in large screen view and so pushes the button to a new line in grid view.

 

So it could be styled as;

('buyqty', '1', 'style="width:60px;text-align:center;"', 'number')

Thank you @@Tsimi so much for the help!

Link to comment
Share on other sites

@@allaboutwicker there is no official addon - everything you require is in this thread. I will summarize for you below.

 

I will make a more "official" addon once the path forward with 2.3.4bs addons is clear. There is/was talk of an "app/addon store" and also app/addon "approval"... I presume these will go hand in hand and not affect the current free addon's (like this one - but just want to be sure.

 

Summary (make sure to make up);

 

for qty box in product_info - see post 9 HERE

 

for qty box in includes/modules/product_listing see post (in 2.3.4BS GOLD) see post 40 HERE

Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...

@@Tsimi

 

I installed on 2.3.4 bootstrap

 

application_top

	// customer adds a product from the products page
          case 'add_product' :  if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                                 $attributes = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : '';
                                 $quantity   = isset($_POST['quantity']) ? max($_POST['quantity']) : 1;
                                 $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $attributes))+$quantity, $attributes);
                                 }
							     $messageStack->add_session('product_action', sprintf(PRODUCT_ADDED, tep_get_products_name((int)$HTTP_POST_VARS['products_id'])), 'success');
                                 tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                                 break;

and product_info.php

    <span class="text-center"><?php echo tep_draw_input_field('quantity[]', '1', 'size="5" style="vertical-align:middle').' '. tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'glyphicon glyphicon-shopping-cart', null, 'primary', '', 'btn btn-success btn-sm btn-block'); ?></span>

Thanks

Link to comment
Share on other sites

@@discxpress

 

I just tested the above code with a BS GOLD shop and it works just fine for me.

Did you add the product_info.php code part before the </form> tag or after?

Did you replace the code inside the application_top.php or did you just add it?

This case here

 case 'add_product' : 

exist already and you have to replace the old case code with that what you just posted.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...