clustersolutions Posted July 10, 2015 Share Posted July 10, 2015 Wrote this module for a new store and tried no core code change but no deal...I have couple questions and any answers are welcome. https://github.com/clustersolutions/osc-price-display-members-only 1 line added to admin/modules.php and I had to use the class file in the catalog side and not the admin because the currencies class aren't the same between the two sides. Perhaps these classes should be consolidated. I wanted the module to be self contained, so I extended the currencies class inside the module, but the procedural step in oscTemplate had called out TEMPLATE_BLOCK_GROUPS = 'boxes;header_tags' in this order and I had to flip the TEMPLATE_BLOCK_GROUPS order around so the boxes would also pickup the change in this module. "update configuration set configuration_value = 'header_tags;boxes' where configuration_key = 'TEMPLATE_BLOCK_GROUPS';" This is what I used, now, is TEMPLATE_BLOCK_GROUPS controlled only from a mysql shell? The alternative would be to add the currencies_mod class file into the class folder and modify the currencies class line in applicaton_top.php. Well, remember my goal was minimum core code change? This method is also kinda messy should the module be uninstalled... May be extending oscTemplates with an updateBlocks() method? Perhaps a class loader would be nice...may be that's already in 2.4 but I had not browsed through the 2.4 codes...but the class loader would have to be very robust and be able to deal with different modules perhaps extending the same class and tinkering with the same method...hmmm?! Any thoughts??? Link to comment Share on other sites More sharing options...
BrockleyJohn Posted July 10, 2015 Share Posted July 10, 2015 Coupla things - how do you create currency as the extended class without a core mod? - why do you want to refer to the currency on the admin side for the module? Aren't you just installing & uninstalling? - I guess by not working unless resequencing you're saying that the currency extension didn't get picked up soon enough. If you want to swap that variable round you could do it in your install function (and put it back in the remove), but I'd manipulate rather than overwrite it. Have you checked if there are unintended consequences to other processing? Assuming this isn't the only thing you're trying to change in your store, maybe it's worth putting a single core change into application top to load extra classes. There'd be no core changes specifically for this mod, and you could use the same hook for other mods. Probably easier to maintain than fiddling with execution order that might have unintended consequences either now or - worse - at some point down the line when you've forgotten about what this mod involved! Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released. Looking for a payment or shipping module? Maybe I've already done it. Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x Link to comment Share on other sites More sharing options...
clustersolutions Posted July 10, 2015 Author Share Posted July 10, 2015 - currencies_mod was extended in the module file, and $currencies was re-initialized in execute(). https://github.com/clustersolutions/osc-price-display-members-only/blob/master/catalog/includes/modules/header_tags/ht_price_display.php - I developed this on edge and is using it on another dev bs platform that's hacked. Yes, install and uninstall from the admin side... - If you look at application_top.php it is still very procedural...I don't see any reason why the block boxes has to executed b4 the header_tags; however I will fix whatever unintentional consequences that may arise. But so far so good. - Another way would be to add a "preloader" thing to TEMPLATE_BLOCK_GROUPS; i.e. "preloader;boxes;header_tags"; but I think I may already be abusing the header_tags block and getting more mileages out of it than I should... - All my sites are on git now...and should this "resequencing" caused any problem I should be able to pinpoint that in the future. - Extending oscTemplates with a updateBlocks() seems like the best deal...but soon enough I may find myself extending to an extension...well u know what I mean... - A more robust way to manage classes without touching the core would be ideal...to me core code change is like all or nothing... - Hey, this happens to any software, just last week a client was telling me they stick with Magento extension from the same company because they guarantee no conflicts :) Coupla things - how do you create currency as the extended class without a core mod? - why do you want to refer to the currency on the admin side for the module? Aren't you just installing & uninstalling? - I guess by not working unless resequencing you're saying that the currency extension didn't get picked up soon enough. If you want to swap that variable round you could do it in your install function (and put it back in the remove), but I'd manipulate rather than overwrite it. Have you checked if there are unintended consequences to other processing? Assuming this isn't the only thing you're trying to change in your store, maybe it's worth putting a single core change into application top to load extra classes. There'd be no core changes specifically for this mod, and you could use the same hook for other mods. Probably easier to maintain than fiddling with execution order that might have unintended consequences either now or - worse - at some point down the line when you've forgotten about what this mod involved! Link to comment Share on other sites More sharing options...
tgely Posted July 10, 2015 Share Posted July 10, 2015 @@clustersolutionsYou could built a preloader block in alhabetic order. For example asomethigpreloader or bootstrap_blocks group names which overtake boxes and header tags in sort order loading. "preloader" name is a bad way. osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
clustersolutions Posted July 10, 2015 Author Share Posted July 10, 2015 @@Gergely, thx, and I agree with you that is probably an easiest fix for now and it allows me to add my extended class. U know, I am so bad at naming variables I think it is harder than naming ur own child...preloader is probably a magic quote? I'll come up with something else...thx, again! Tim @@clustersolutionsYou could built a preloader block in alhabetic order. For example asomethigpreloader or bootstrap_blocks group names which overtake boxes and header tags in sort order loading. "preloader" name is a bad way. Link to comment Share on other sites More sharing options...
tgely Posted July 11, 2015 Share Posted July 11, 2015 @@clustersolutionsI have combined your idea with this addon and its perfect! I used as bootstrap modules not 960gs. http://addons.oscommerce.com/info/8860 bt_price_display.php $group = 'bootstrap'; and so onnew products and all boxes working well. <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2015 osCommerce Author: Cluster Solutions Released under the GNU General Public License */ class bt_price_display { var $code = 'bt_price_display'; var $group = 'bootstrap'; var $title; var $description; var $sort_order; var $enabled = false; function bt_price_display() { $this->title = MODULE_BOOTSTRAP_PRICE_DISPLAY_TITLE; $this->description = MODULE_BOOTSTRAP_PRICE_DISPLAY_DESCRIPTION; if ( defined('MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS') ) { $this->sort_order = MODULE_BOOTSTRAP_PRICE_DISPLAY_SORT_ORDER; $this->enabled = (MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS == 'True'); } } function execute() { global $oscTemplate, $currencies; $currencies = new currencies_mod(); $oscTemplate->addBlock('<script>$(".remove").closest(".btn-group").remove()</script>', 'footer_scripts'); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Price Display Control', 'MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS', 'True', 'Do you want to enable price display control for members only?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOOTSTRAP_PRICE_DISPLAY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS', 'MODULE_BOOTSTRAP_PRICE_DISPLAY_SORT_ORDER'); } } if (class_exists('currencies')) { class currencies_mod extends currencies { public function display_price($products_price, $products_tax, $quantity = 1) { global $customer_id; if (tep_session_is_registered('customer_id') && defined(MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS) && MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS == 'True') { return $this->format($this->calculate_price($products_price, $products_tax, $quantity)); } else { return '<div class="remove"></div>'; } } } } ?> admin cfg: <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2012 osCommerce Released under the GNU General Public License */ class cfgm_bootstrap { var $code = 'bootstrap'; var $directory; var $language_directory = DIR_FS_CATALOG_LANGUAGES; var $key = 'MODULE_BOOTSTRAP_INSTALLED'; var $title; var $template_integration = true; function cfgm_bootstrap() { $this->directory = DIR_FS_CATALOG_MODULES . 'bootstrap/'; $this->title = MODULE_CFG_MODULE_BOOTSTRAP_TITLE; } } ?> Great! osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
BrockleyJohn Posted July 11, 2015 Share Posted July 11, 2015 @@clustersolutions @@Gergely B) B) Now if only there was a product class I could extend to override other stuff on the product info page... Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released. Looking for a payment or shipping module? Maybe I've already done it. Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x Link to comment Share on other sites More sharing options...
tgely Posted July 11, 2015 Share Posted July 11, 2015 @@BrockleyJohn yes this is the goal. osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
clustersolutions Posted July 11, 2015 Author Share Posted July 11, 2015 @@Gergely...sweet!!! Thx so much!!! Link to comment Share on other sites More sharing options...
clustersolutions Posted July 11, 2015 Author Share Posted July 11, 2015 repository updated... https://github.com/clustersolutions/osc-price-display-members-only Link to comment Share on other sites More sharing options...
ClauDom Posted July 18, 2015 Share Posted July 18, 2015 Hi, I am testing this good option, and it works but... if a guest starts adding products to the cart, the "Sub-Total" shows the price. Could you fix this? thank you very much! Link to comment Share on other sites More sharing options...
tgely Posted July 18, 2015 Share Posted July 18, 2015 One possible fix in currencies_mod function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { global $currency, $customer_id; if (empty($currency_type)) $currency_type = $currency; if ($calculate_currency_value == true) { $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value']; $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; } else { $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; } if (tep_session_is_registered('customer_id')) { return $format_string; } else { return '<div class="remove"></div>'; } } osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
ClauDom Posted July 19, 2015 Share Posted July 19, 2015 Yes Gergely, It worked! Thank you very much. Link to comment Share on other sites More sharing options...
clustersolutions Posted July 19, 2015 Author Share Posted July 19, 2015 That works...excellent!!! Repository updated... https://github.com/clustersolutions/osc-price-display-members-only One possible fix in currencies_mod function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { global $currency, $customer_id; if (empty($currency_type)) $currency_type = $currency; if ($calculate_currency_value == true) { $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value']; $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; } else { $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; } if (tep_session_is_registered('customer_id')) { return $format_string; } else { return '<div class="remove"></div>'; } } Link to comment Share on other sites More sharing options...
tgely Posted July 25, 2015 Share Posted July 25, 2015 @@clustersolutions '<div class="remove"></div>'; appears in attributes for me. osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
clustersolutions Posted July 25, 2015 Author Share Posted July 25, 2015 @@Gergely, that was just for removing the button around the price when it is hidden. Perhaps it won't be necessary if u don't wrap the price in a button under category/product page? It was a quick fit...I don't use it as I don't wrap my price inside a button...would it cause any problem? Link to comment Share on other sites More sharing options...
tgely Posted July 26, 2015 Share Posted July 26, 2015 @@clustersolutions generally not cause any problem but would be nicely display nothing. or a simple space. osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
clustersolutions Posted July 30, 2015 Author Share Posted July 30, 2015 @@Gergely, true, will look into another way to remove the btn that wraps the price... Link to comment Share on other sites More sharing options...
tgely Posted July 30, 2015 Share Posted July 30, 2015 @@Gergely, true, will look into another way to remove the btn that wraps the price... $oscTemplate->addBlock('<script>$("option").each(function () { $(this).text($(this).text().replace(\'<div class="remove"></div>\',\'\')); });</script>', 'footer_scripts'); osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
clustersolutions Posted August 1, 2015 Author Share Posted August 1, 2015 @@Gergely, that'll work...a bandaid for another bandaid? Link to comment Share on other sites More sharing options...
Alexandr1 Posted December 10, 2016 Share Posted December 10, 2016 Здравствуйте Сергей. Я установил на сервер все файлы. Но редактировать не понимаю как . У меня различаются файлы PHP с Вашими. У меня нет того что надо заменить. Установлена вот эта версия.oscommerce_2.3.4_bootstrap_rus. Помогите, 2. includes/template_top.php Change: <link rel="stylesheet" type="text/css" href="ext/960gs/<?php echo ((stripos(HTML_PARAMS, 'dir="rtl"') !== false) ? 'rtl_' : ''); ?>960_24_col.css" /> to: <?php if ($oscTemplate->getGridContainerWidth() != '24') { $oscTemplate->setGridMarginWidth(20); } if (defined(MODULE_960GS_CSS_DEVELOPER_COLUMNS_STATUS) && MODULE_960GS_CSS_DEVELOPER_COLUMNS_STATUS == 'True') { ?> <style> #bodyWrapper<?php echo $oscTemplate->getBlocks('960grid_css_developer'); ?> { background: url("ext/960gs/grid_draw.php?w=960&c=<?php echo $oscTemplate->getGridContainerWidth(); ?>&m=<?php echo $oscTemplate->getGridMarginWidth(); ?>") repeat-y scroll 0 0 transparent; } </style> <?php } ?> <link rel="stylesheet" type="text/css" href="ext/960gs/<?php echo ((stripos(HTML_PARAMS, 'dir="rtl"') !== false) ? 'rtl_' : ''); ?>960_<?php echo $oscTemplate->getGridContainerWidth(); ?>_col.css" /> Change: <div id="bodyWrapper" class="container_<?php echo $oscTemplate->getGridContainerWidth(); ?>"> To: <div id="bodyWrapper<?php echo $oscTemplate->getBlocks('960grid_css_developer'); ?>" class="container_<?php echo $oscTemplate->getGridContainerWidth(); ?>"> Change: if (!$oscTemplate->hasBlocks('boxes_column_left')) { $oscTemplate->setGridContentWidth($oscTemplate->getGridContentWidth() + $oscTemplate->getGridColumnWidth()); } if (!$oscTemplate->hasBlocks('boxes_column_right')) { $oscTemplate->setGridContentWidth($oscTemplate->getGridContentWidth() + $oscTemplate->getGridColumnWidth()); } to: if (!$oscTemplate->hasBlocks('boxes_column_left')) { $oscTemplate->setGridContentWidth($oscTemplate->getGridContentWidth() + $oscTemplate->getGridLeftColumnWidth()); } if (!$oscTemplate->hasBlocks('boxes_column_right')) { $oscTemplate->setGridContentWidth($oscTemplate->getGridContentWidth() + $oscTemplate->getGridRightColumnWidth()); } Change: <div id="bodyContent" class="grid_<?php echo $oscTemplate->getGridContentWidth(); ?> <?php echo ($oscTemplate->hasBlocks('boxes_column_left') ? 'push_' . $oscTemplate->getGridColumnWidth() : ''); ?>"> to: <div id="bodyContent" class="grid_<?php echo $oscTemplate->getGridContentWidth(); ?> <?php echo ($oscTemplate->hasBlocks('boxes_column_left') ? 'push_' . $oscTemplate->getGridLeftColumnWidth() : ''); ?>"> Link to comment Share on other sites More sharing options...
Portman Posted August 2, 2018 Share Posted August 2, 2018 Hey @clustersolutions this addon is great and is really what I need for my B2B website... I am wondering if you could give me a few pointers on how to modify it a bit to work for my store - which is strictly Wholesale only . I don't want non authorised members being able to see prices or generate orders . I am using SPPC on my site and would really like to modify 'display price for login members only' so that it checks if the customer is part of the default SPPC group (customers_group_id = 0) so that if they are part of group 0 they are treated as not being logged in. It is only once their status to another SPPC group has been updated in admin that they can see prices. The 'customers_group_id' field is in the customers table so it should not be to hard to do, but I just can't get my head around it - have you got any thoughts on where I should start? Link to comment Share on other sites More sharing options...
clustersolutions Posted August 3, 2018 Author Share Posted August 3, 2018 Your requirements still kinda vague, it can be done, but you will need to get familiar with both modules/apps in order to integrate it. May be try to ask some more specific questions? I will have to wait until I have the time to refresh my memory on even my own codes...thx! Link to comment Share on other sites More sharing options...
Portman Posted August 3, 2018 Share Posted August 3, 2018 Ok... here goes, SPPC allows you to create a number of customer groups to allow different prices for different customer groups. The default group is 0, then you have groups 1,2,3 etc which are applied on the admin side of the site. as part of the mod an extra field is added to the ‘customers’ table called ‘customers_group_id’ when a new customer creates an account that is set to 0. What I was hoping to do was to modify your app so that it does not show prices if the customer is not logged in, but it also does not show prices if the customers_group_id is 0 (essentially meaning that they don’t see prices and cannot purchase from my site until I have approved them by setting customer_group_id to something other than 0) Link to comment Share on other sites More sharing options...
clustersolutions Posted August 6, 2018 Author Share Posted August 6, 2018 @Portman This is where you can make it happen...it was a simple module. https://github.com/clustersolutions/osc-price-display-members-only/blob/9f3970e9e8dbf8deabe2100dbb5ff69a5db5e9c4/catalog/includes/modules/bootstrap/bt_price_display.php#L67 You will need to make sure that the $customers_group_id was already registered as a session variable before this module. Modify the if conditional statement to validate $customers_group_id per your requirements.. if (tep_session_is_registered('customer_id') && tep_session_is_registered('customers_group_id') && $customers_group_id > 0 && defined(MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS) && MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS == 'True') { . . . I hope this make sense...but you need to test it to be sure. https://github.com/clustersolutions/osc-price-display-members-only/blob/9f3970e9e8dbf8deabe2100dbb5ff69a5db5e9c4/catalog/includes/modules/bootstrap/bt_price_display.php#L67 if (tep_session_is_registered('customer_id') && defined(MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS) && MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS == 'True') { if (tep_session_is_registered('customer_id') && defined(MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS) && MODULE_BOOTSTRAP_PRICE_DISPLAY_STATUS == 'True') { Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.