Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basket/Cart plugin for GetSimple
#12
Hello, Cupuyc1989

Nice work, but not quite finished yet, I think.

You are showing the small basket by a 'index-posttemplate'-hook. At the point in time when this gets called, the complete html has already been rendered and your basket sits beyond the closing "</html>". If browsers weren't so very lenient with bad html, it would not get shown. A better way to do this would be a content-filter. So line 120 of basket-plugin
should read:

PHP Code:
add_filter('content','basket_small_show'); 

instead of:

PHP Code:
add_action('index-posttemplate','basket_small_show'); 


and the function basket_small_show should look more or less like this:

PHP Code:
function basket_small_show($content) {

 
       global $basket_settings
 
       global $MESS;

 
       $new='<div id="basket" style="'.$basket_settings['BASKET_STYLES'].'">';
 
       // if cart has items
 
       if (!empty($_SESSION['BASKET']['ITEMS'])) {
 
         // show it to user
 
         $new.='<a href="?basket=Y" title="'.$MESS['cart_small_link_title'].'">'.$MESS['cart_small_cart_items_message'].' - '.count($_SESSION['BASKET']['ITEMS']).' '.$MESS['cart_small_cart_items_message_count'].' '.$MESS['cart_small_cart_items_sum'].' '.$_SESSION['BASKET']['SUM'].' '.$basket_settings['CURRENCY'].'</a>';
 
       }
 
       // or show "empty" message
 
       else 
 
         $new.=$MESS['cart_small_empty_basket_message'];
 
       }
 
       if ($basket_settings['SHOW_HISTORY_TO_USER'] == 'Y') {
 
         $new.='<br><center><a href="?history=Y" title="'.$MESS['show_history_link_text'].'">'.$MESS['show_history_link_text'].'</a></center>';
 
       }
 
       $new.='</div>';
 
       // echo $content;
 
       return $content.$new;




Also, the plugin writes it's configuration and data into files and directories in 'plugins/basket_plugin/'. That location is not necessarily writeable (at least, the way I set GetSimple up for local development it wasn't) and fails without giving notice. A subdirectory of 'data/other/' would be a better choice, especially since there's already a constant GSDATAOTHER defined in admin/inc/common.php for exactly this purpose.

Another inconsistency is the encoding of the mail: you're giving a content-type of "text/html charset=utf8" and then encoding the message in KOI8 ... shouldn't that be Unicode, too ?

And then there's all the inline styles in the html-output. A couple of css-classes would probably shorten the html and make theming of the cart possible, especially if it was set up as a separate .css-file.

Please see my comments as constructive criticism and not as malicious nit-picking.

H.
Reply


Messages In This Thread
Basket/Cart plugin for GetSimple - by Cupuyc1989 - 2014-08-03, 05:06:21
RE: Basket plugin for GetSimple - by shawn_a - 2014-08-03, 09:28:09
RE: Basket plugin for GetSimple - by Cupuyc1989 - 2014-08-06, 04:49:08
RE: Basket/Cart plugin for GetSimple - by Lars - 2014-08-20, 04:11:19
RE: Basket/Cart plugin for GetSimple - by D.O. - 2014-09-04, 20:40:31
RE: Basket/Cart plugin for GetSimple - by Artur - 2015-06-06, 20:13:31
RE: Basket/Cart plugin for GetSimple - by morvy - 2015-06-08, 09:02:03
RE: Basket/Cart plugin for GetSimple - by morvy - 2015-06-12, 08:53:47
RE: Basket/Cart plugin for GetSimple - by Bigin - 2015-06-12, 16:10:11
RE: Basket/Cart plugin for GetSimple - by hddg - 2015-11-02, 09:22:39
RE: Basket/Cart plugin for GetSimple - by Oleg06 - 2020-05-02, 18:05:34
RE: Basket/Cart plugin for GetSimple - by NCardia - 2020-11-18, 06:22:04
RE: Basket/Cart plugin for GetSimple - by NCardia - 2020-11-18, 06:26:37



Users browsing this thread: 1 Guest(s)