cs36 Posted April 23, 2018 Share Posted April 23, 2018 Hello, I am working on migrating our shopping cart to the newer 2.3.4.1BS version. However, unless I am not seeing it, one feature that is missing (that I actually also had to add on the old 2.2 version as well) is the ability to select the quantity to add to the cart when selecting "add to cart" or "buy". I tried adding this add-on: HERE, but I can't seem to get it to work if the product has attributes. I would also like to be able to add it not only to the product info page, but also the product (category?) listing and any other page you can purchase the products. I was able to do it on MS2.2, but haven't been able to get it to work on 2.3.4.1BS so far so any help would be appreciated. Link to comment Share on other sites More sharing options...
Jack_mcs Posted April 23, 2018 Share Posted April 23, 2018 You will need to install an addon but there isn't one, that I am aware of, for the latest BS version. The one you are using can be made to work but it would require code changes. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cs36 Posted April 23, 2018 Author Share Posted April 23, 2018 2 hours ago, Jack_mcs said: You will need to install an addon but there isn't one, that I am aware of, for the latest BS version. The one you are using can be made to work but it would require code changes. That's what I am looking for. I modified the one I found to sort of work, but it doesn't work if the product has attributes. Not entirely sure why this isn't a default feature. I've never been to a site where I couldn't input the quantity I wanted to buy. Link to comment Share on other sites More sharing options...
greasemonkey Posted April 23, 2018 Share Posted April 23, 2018 @cs36 I have this done but it requires a change to application_top, products_listing & product_info (unless you are using the absolute latest EDGE that I believe is now using product info content modules).... changing the core is the only way I know how to to accomplish this... and its frowned upon. I won't share it here... but feel free to PM me... Link to comment Share on other sites More sharing options...
♥Tsimi Posted April 24, 2018 Share Posted April 24, 2018 @cs36 Just as info, if a product has attributes it will always redirect you to the product info page. That is normal osC behavior. Even if you add a quantity input field it will behave the same way. If you say you had it working on your old shop then you most likely will have to look into the application_top.php file since the redirect to the product page is defined in there. The add-on you linked in your post, the one from greasemonkey, works just fine in a osC BS shop. Just need to slightly change the code for to match the visual part. Link to comment Share on other sites More sharing options...
♥raiwa Posted April 24, 2018 Share Posted April 24, 2018 @cs36, You can get it to work with attributes, but then you have to retrieve the attributes and show the options/attributes selections in the product listing. I saw this in some old 2.2/2.3 standard store. But I do not remember if there exists an add-on or if it was custom coded. It requires much more modifications than the add to cart button. But if you say you had this working in your old store, you just need to replicate the coding and adapt it to the BS store. About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥Tsimi Posted April 24, 2018 Share Posted April 24, 2018 I found this attributes in product listing idea interesting and thought I give this a go and I think I got it more or less working. Be aware that the following is only showing on products within the category itself and not on the "New Products for..." listing. (content modules index and index_nested)This requires core code changes, (backup your files first!) and if someone wants to modularize this somehow then please go ahead but test this thoroughly before doing so. I didn't had the time to do a full bug hunt. Also this was coded and tested on an older verison of osC Edge (6. March 2018) which doesn't contain the modularized application top actions. First lets add a new action ../includes/application_top.php FIND case 'cust_order' : if (tep_session_is_registered('customer_id') && isset($_GET['pid'])) { if (tep_has_product_attributes($_GET['pid'])) { tep_redirect(tep_href_link('product_info.php', 'products_id=' . $_GET['pid'])); } else { $cart->add_cart($_GET['pid'], $cart->get_quantity($_GET['pid'])+1); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; ADD AFTER // BOF Attributes in product listing and qty input field case 'buy_now_form' : if (isset($_POST['products_id'])) { $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+($_POST['cart_quantity']), $_POST['id']); } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; // EOF Attributes in product listing and qty input field Inside the ../includes/modules/product_listing.php FIND if (tep_not_null($extra_list_contents)) { $prod_list_contents .= ' <dl class="dl-horizontal list-group-item-text">'; $prod_list_contents .= $extra_list_contents; $prod_list_contents .= ' </dl>'; } ADD AFTER // BOF Attributes in product listing and qty input field $prod_list_contents .= '<form name="buy_now_' . $listing['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now_form', 'NONSSL') . '">'; $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . $listing['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { $prod_list_contents .= '<div class="clearfix"></div>'; $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $prod_list_contents .= '<label>' . $products_options_name['products_options_name'] . ':</label><br />'; $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } $prod_list_contents .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$_GET['products_id']]['attributes'][$products_options_name['products_options_id']], 'style="width: 250px;"'). '<br />'; } } $prod_list_contents .= '<div class="text-right">'; $prod_list_contents .= '<label>Quantity</label> ' . tep_draw_input_field('cart_quantity', 1, 'style="width:70px;text-align:center;"'); $prod_list_contents .= '</div>'; // EOF Attributes in product listing and qty input field FIND $prod_list_contents .= tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'fa fa-shopping-cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . ((tep_has_product_attributes((int)$listing['products_id']) === true) ? '1' : '0') . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-success btn-product-listing btn-buy'); REPLACE WITH // BOF Attributes in product listing and qty input field $prod_list_contents .= tep_draw_hidden_field('products_id', $listing['products_id']) . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'fa fa-shopping-cart'); $prod_list_contents .= '</form>'; // EOF Attributes in product listing and qty input field That's it. Again this was just quickly put together using an old add-on as template so test this thoroughly before using on a live shop. And this is how it should look like. Link to comment Share on other sites More sharing options...
greasemonkey Posted April 24, 2018 Share Posted April 24, 2018 @Tsimi that is nicer than the one I shared with him..... putting the attributes right in the product listing.... Link to comment Share on other sites More sharing options...
cs36 Posted April 24, 2018 Author Share Posted April 24, 2018 @Tsimi That works perfect. And like greasemonkey said it is very nice and clean. Now, how can I basically do the same thing in the product info page? Link to comment Share on other sites More sharing options...
♥Tsimi Posted April 24, 2018 Share Posted April 24, 2018 There are a few possible solutions for the product info page. Drop down select? Input select? Input select with + and - buttons. http://bfy.tw/Hor4 Take your pick. Link to comment Share on other sites More sharing options...
cs36 Posted April 25, 2018 Author Share Posted April 25, 2018 Thanks Tsimi. I originally thought it was an extension on your code, but now I see how it works and that it is separate and got it on the info page as well. Now I'm working on getting the qty box on the "new products" listing module on the main page. Link to comment Share on other sites More sharing options...
♥Tsimi Posted April 26, 2018 Share Posted April 26, 2018 @cs36 We did enough core code changes with the product listing and probably inside the product info page as well. So let's try to avoid core code changes this time. In the following zip package you find 2 new modules. "New Products for..." index and index_nested modules. Just uninstall the stock osC new products modules (index and index_nested) upload the files from the package and install them. Done! Here again test this and make sure everything is working as it suppose to. new_products_with_attributes_BS.zip And a small update regarding the code for the button inside the product listing page. FIND // BOF Attributes in product listing and qty input field $prod_list_contents .= tep_draw_hidden_field('products_id', $listing['products_id']) . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'fa fa-shopping-cart'); $prod_list_contents .= '</form>'; // EOF Attributes in product listing and qty input field REPLACE WITH // BOF Attributes in product listing and qty input field $prod_list_contents .= tep_draw_hidden_field('products_id', $listing['products_id']) . '<button class="btn btn-success" type="submit"><i class="fa fa-shopping-cart"></i> ' . IMAGE_BUTTON_BUY_NOW . '</button>'; $prod_list_contents .= '</form>'; // EOF Attributes in product listing and qty input field Link to comment Share on other sites More sharing options...
cs36 Posted April 26, 2018 Author Share Posted April 26, 2018 @Tsimi That works perfect! Thanks! Link to comment Share on other sites More sharing options...
René H4 Posted April 26, 2018 Share Posted April 26, 2018 Will this become an official add-on? I am in need of it too! :-) Link to comment Share on other sites More sharing options...
♥Tsimi Posted April 26, 2018 Share Posted April 26, 2018 @honda4 This most likely won't become an add-on. The product listing part and the product info part have core code changes and that is not what I want to put in the add-ons section. And adding only the 2 New products for... modules as add-on is not ideal without the product listing part. You find what you need here in this thread. Take what you need and use it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.