2015-11-02, 09:22:39
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:
instead of:
and the function basket_small_show should look more or less like this:
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.
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.