[TYPO3-commerce] Show scaled prices in basket & redirect to previous page after buying article
Franz Koch
typo.removeformessage at fx-graefix.de
Tue Nov 6 09:16:55 CET 2007
Morning,
> At the moment we have two questions about some special features:
>
> 1. In the shop we're using scaled prices for e.g. note paper. So if the
> customer orders a amount of 100 he will pay 34 Euro (34 cent each), at
> 200 he will pay 44 Euro (22 cent each) and so on. We only use net
> prices, because it's a true b2b-shop.
>
> The problem is now, that always the first price (34 cent) of the scaled
> prices is shown. Both in the detailview and in the basket. We would like
> to show the current scaled price, for example 22 cent if the customer
> has selected a amount between 200 and 299. Is there already a marker or
> a function, or do we have to use a hook? I've already looked in the
> source, there a plenty of hooks but probably I've overlook another
> opportunity?
In the basket, you should always see the correctly scaled price - if
not, something is wrong. It at least works in my installation, and I
also only use net prices (b2b-shop), but I tweaked quite a lot for a
better handling of only net prices.
For the scaled prices in the detail view - I coded a little snippet for
one of the marker hooks:
----
Hook:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['articleMarker']
----
function additionalMarkerArticle($markerArray,&$article,&$parent) {
$data = &$article->returnAssocArray();
$piVars = &$parent->piVars;
// scaled prices - but for now only in singleView
$markerArray['ARTICLE_SCALE_PRICES'] = '';
if($piVars['showUid']) {
$scaledPrices = $article->getPriceScaleObjects(2);
if(is_array($scaledPrices) && count($scaledPrices)) {
$scaleMarker = array();
$scaleTemplateTotal =
$parent->cObj->getSubpart($parent->templateCode,'###SCALED_PRICES###');
$scaleTemplateItem =
$parent->cObj->getSubpart($scaleTemplateTotal,'###SCALED_PRICE_ITEM###');
foreach($scaledPrices as $startValue => $array) {
$priceObject = current($array);
$scaleMarker['###SCALE_START###'] = intval($startValue);
$scaleMarker['###SCALE_END###'] = intval(key($array));
$scaleMarker['###SCALE_PRICE_NET###'] =
tx_moneylib::format($priceObject->get_price_net(),$parent->currency);
$scaleMarker['###SCALE_PRICE_GROSS###'] =
tx_moneylib::format($priceObject->get_price_gross(),$parent->currency);
$scaleItems[$startValue] =
$parent->cObj->substituteMarkerArrayCached($scaleTemplateItem,$scaleMarker);
}
ksort($scaleItems);
$scaleSubpartArray['###SCALED_PRICE_ITEM###'] =
implode('',$scaleItems);
$markerArray['ARTICLE_SCALE_PRICES'] =
$parent->cObj->substituteMarkerArrayCached($scaleTemplateTotal,array(),$scaleSubpartArray);
}
}
return $markerArray;
}
----
> 2. If an article has been added to the basket, the large view of the
> basket pops up. Is it possible (maybe by setting a parameter in
> typoscript) to redirect to the previous page?
I'm not aware of such a functionality, but you can use one of the hooks
for that. But not 'postartAddUid', because not all basket handling is
finished on that point and the basket isn't stored yet. Maybe you can
use
'$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['generateBasketMarker']'
for it - although it causes some overhead because of the marker processing.
Hope that helps.
--
Kind regards,
Franz Koch
More information about the TYPO3-project-commerce
mailing list