[solved] Cart - Smarty or UDT for delleting product with specific id from Cart
Posted: Mon Sep 13, 2010 9:57 pm
Hello, I'm still struggling with quite specific e-shop and now i get stuck with making page, where customer can choose from several delivery methods. Because I didn't find module, which allow customer choose from different delivery methods, which have different prices, and at tops I also need free delivery, when total price is higher than x, I'm trying to do simple page, where choose of delivery company simply adds specific product (example of product: UPS Packet) to the Cart. That isn't so difficult, but when customer do that, than he (for some reason) return back to the shop, and then he visit this delivery selection page again, It would add second delivery product to the Cart and he will pay it twice. So I would like to add some smarty or UDT on top of this page, which simply look into the Cart, and if there will be product with specified id (which will be these delivery method products), it will remove it from Cart. (And then user chooses method again, it will add it again, and everything is fine...)
I'm of course trying to figure it out myself and so far my Delivery method page looks like this:
{Cart product=7} // this is one of the delivery methods products
{Cart action='viewcart' viewcarttemplate='viewcart_init'} // viewcart_init template is absolutely blank, I just get Cart variables filled in
and now, when I put there {$cartitems|print_r}, If i understand it right, i have there array with Objects, which represents Products. For sure, I'll put the output there, because I'm still not big friend with arrays and objects... (In this example, there are two products in cart: )
So now I need smarty or UDT, which comes to top of my page and my thinking goes this way:
{foreach from objects in $cartitems}
{if id of product == x}
delete from $cartitems object with this id
{/if}
{/foreach}
So I hope, that you understand my crappy English and I will be very appreciated for any help or advice.
I'm of course trying to figure it out myself and so far my Delivery method page looks like this:
{Cart product=7} // this is one of the delivery methods products
{Cart action='viewcart' viewcarttemplate='viewcart_init'} // viewcart_init template is absolutely blank, I just get Cart variables filled in
and now, when I put there {$cartitems|print_r}, If i understand it right, i have there array with Objects, which represents Products. For sure, I'll put the output there, because I'm still not big friend with arrays and objects... (In this example, there are two products in cart: )
Code: Select all
stdClass Object ( [product_id] => 2 [sku] => 00301 [quantity] => 1 [base_price] => 0 [type] => 1 [pending] => [unit_weight] => 0 [unit_price] => 123 [summary] => Makové snění Platno - 20x30 (123.00) [item_total] => [file_location] => http://localhost/linnette-obrazy/uploads/Products/product_2 [flds] => Array ( [image] => stdClass Object *RECURSION* [pomer_stran] => stdClass Object *RECURSION* ) [categories] => Array ( [0] => stdClass Object ( [id] => 1 [name] => Bokeh [value] => [file_location] => http://localhost/linnette-obrazy/uploads/Products/categories/1 ) [1] => stdClass Object ( [id] => 2 [name] => Detail a zátiší [value] => [file_location] => http://localhost/linnette-obrazy/uploads/Products/categories/2 ) [2] => stdClass Object ( [id] => 3 [name] => Anything else [value] => [file_location] => http://localhost/linnette-obrazy/uploads/Products/categories/3 ) ) [quantity_box] => [remove_box] => ) stdClass Object ( [product_id] => 7 [sku] => [quantity] => 1 [base_price] => 100 [type] => 1 [pending] => [unit_weight] => 0 [unit_price] => 100 [summary] => Poštovné - Česká Pošta [item_total] => [file_location] => http://localhost/linnette-obrazy/uploads/Products/product_7 [flds] => Array ( [image] => stdClass Object *RECURSION* [pomer_stran] => stdClass Object *RECURSION* ) [categories] => Array ( [0] => stdClass Object ( [id] => 1 [name] => Bokeh [value] => [file_location] => http://localhost/linnette-obrazy/uploads/Products/categories/1 ) [1] => stdClass Object ( [id] => 2 [name] => Detail a zátiší [value] => [file_location] => http://localhost/linnette-obrazy/uploads/Products/categories/2 ) [2] => stdClass Object ( [id] => 3 [name] => Anything else [value] => [file_location] => http://localhost/linnette-obrazy/uploads/Products/categories/3 ) ) [quantity_box] => [remove_box] => ) Array Array
{foreach from objects in $cartitems}
{if id of product == x}
delete from $cartitems object with this id
{/if}
{/foreach}
So I hope, that you understand my crappy English and I will be very appreciated for any help or advice.