Forums / Setup & design / item_count always 1

item_count always 1

Author Message

Steve P

Wednesday 25 May 2005 7:47:16 am

Hello

I am having trouble setting item_count to always be 1 in the shop/basket? Probably my bad sytax :(

Any ideas?

Thanks

Steve

Łukasz Serwatka

Thursday 26 May 2005 12:21:16 am

Hi Steve,

Syntax is very simple:

{let basket=fetch( 'shop', 'basket' )}
    {count( $basket.items )}
{/let}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Steve P

Thursday 26 May 2005 3:11:35 am

Thanks, but not sure I explained what I want to do. In plain english I'd like to achieve something like:

If the quantity of a product {$product_item.item_count} is greater than 1 set quantiy to 1 & echo "you have already ordered {$product_item.object_name}!!"

For some reason I can't seem to re-set {$product_item.item_count}?

Best

Steve

Łukasz Serwatka

Thursday 26 May 2005 3:38:44 am

Could you show your code?

This example checks if quantity is greater then 1, reseting quantity to 1 on template level only. Look in to kernel/shop/basket.php

{let basket=fetch( 'shop', 'basket' )}
    {section var=product_item loop=$basket.items}
        {section show=$product_item.item_count|gt(1)}
            you have already ordered
            <input type="text" name="ProductItemCountList[]" value="1" size="5" />
        {section-else}
            <input type="text" name="ProductItemCountList[]" value="{$product_item.item_count}" size="5" />
        {/section}
    {/section}
{/let}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Steve P

Thursday 26 May 2005 3:56:39 am

Thank you Lukasz.

Your code displays correctly when item_count is greater than 1. I have been tying to insert something like:
<let>($product_item.item_count=1)</let> in the basket loop [& lots of variations in syntax] with no luck.

$product_item.item_count should aways be 1 for this application.

Steve P

Thursday 26 May 2005 4:22:15 am

Ahh! Becoming clearer. The data has already been written? So I could nobble the kernal here [is this a good idea?]

    if ( $itemID )
    {
        /* If found in the basket, just increment number of that items: */
        $item =& eZProductCollectionItem::fetch( $itemID );
        $item->setAttribute( 'item_count', 1 + $item->attribute( 'item_count' ) );
        $item->store();
    }

...or maybe set item_count to 1 in the template, display a warning & present a button to write the quantiy???

This is a great help - thanks!

Chris Lan

Wednesday 23 November 2005 7:17:49 am

Lukasz, Steve, friends,

I am fighting to implement a simple functionnality since three days but the only thing I succeed is to create bugs and bugs.

I just want to add in kernel/basket.php a control if he find the item, he does not add it again as they're only one sample of each.

My best result is :

if ( $http->hasPostVariable( "ActionAddToBasket" ) )
{
    $objectID = $http->postVariable( "ContentObjectID" );

    if ( $http->hasPostVariable( 'eZOption' ) )
        $optionList = $http->postVariable( 'eZOption' );
    else
        $optionList = array();
		$itemIDList = $http->postVariable( "ProductItemIDList" );
    	$i = 0;

The issue is when I use "continue shopping" it delete the content of my basket. I am lost. Please be merciful with a newbie ez.

Thanks,
Chris

eZ debug

Timing: Jan 19 2025 07:16:53
Script start
Timing: Jan 19 2025 07:16:53
Module start 'content'
Timing: Jan 19 2025 07:16:53
Module end 'content'
Timing: Jan 19 2025 07:16:53
Script end

Main resources:

Total runtime0.1861 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 588.9297180.8438
Module start 'content' 0.00650.0051 769.7734101.9609
Module end 'content' 0.01160.1744 871.7344529.7500
Script end 0.1860  1,401.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00341.8382200.0002
Check MTime0.00140.7569200.0001
Mysql Total
Database connection0.00080.440110.0008
Mysqli_queries0.142376.47681410.0010
Looping result0.00140.73581390.0000
Template Total0.174093.510.1740
Template load0.00080.450810.0008
Template processing0.173293.066010.1732
Override
Cache load0.00060.315410.0006
Sytem overhead
Fetch class attribute can translate value0.00070.386910.0007
XML
Image XML parsing0.00020.123010.0002
General
dbfile0.00241.3085200.0001
String conversion0.00000.004430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs