Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Square meter contrib


  • You cannot reply to this topic
5 replies to this topic

#1 drferrari

  • Community Member
  • 11 posts
  • Real Name:drferrari
  • Gender:Male
  • Location:Greece

Posted 06 January 2012, 19:12

I try create my own square meter contrib, I have stuck.

in products_info.php page I create

 
<input type="text" id="widthValue" name="widthValue" value="" size="5"/> x <input type="text" id="heightValue" name="heightValue" value="" size="5"/>



this value is goto my shopping cart.

in shopping_cart.php page
if($products[$i]['widthValue'] !== ''){
$totalSquereMeter = $products[$i]['widthValue'] * $products[$i]['heightValue'];
$info_box_contents[] = array('params' => 'class="productListing-data2"',
'text' => '<br/>WIDTH:'.$products[$i]['widthValue'].' x HEIGHT:'.$products[$i]['heightValue'].' = '.$totalSquereMeter);

AND THIS is if products have width and height. I don't wanna show quantity if I have add product with WIDTH and HEIGHT.

if($products[$i]['widthValue'] == ''){
echo"NO width and height";
$info_box_contents[$cur_row][] = array('align' => 'center',
'params' => 'class="productListing-data2" valign="top"',
'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));
}else{
echo"width and height";
$info_box_contents[$cur_row][] = array('align' => 'center',
'params' => 'class="productListing-data2" valign="top"',
'text' => $products[$i]['quantity']);
}

in file -> includes/aplication_top.php

$cart->add_cart(
$HTTP_POST_VARS['products_id'][$i],
$HTTP_POST_VARS['cart_quantity'][$i],
$HTTP_POST_VARS['widthValue'][$i], $HTTP_POST_VARS['heightValue'][$i],
$attributes, false);

the problem is when I add product to shopping cart with WIDTH and HEIGHT then I can't delete it.

I try this

'text' => tep_draw_hidden_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

NOW I can delete all my products

BUT

this is WRONG if I have

product A (with = 2 height =3) and
product B (no width and height)

AND if I change quantity of my second product this qantity value goes to my first product.

any Idea for this.

#2 DunWeb

  • Community Sponsor
  • 10,466 posts
  • Real Name:Chris Dunn
  • Gender:Male
  • Location:Tecumseh, Ontario, Canada N8N 1X8

Posted 06 January 2012, 19:48

There is an commercial add for this called Area Calculator 2.3.1 if you want to Google for it, or you can check my profile links.



Chris
:|: Was this post helpful ? Click the LIKE THIS button :|:

:|: Click Here to learn how I can help you with custom coding, add ons, security and templates :|:

:|: Need an Area Calculator, Pre-Paid Account, Virtual Pin, Auction or Layaway Add on ? Click Here :|:

#3 drferrari

  • Community Member
  • 11 posts
  • Real Name:drferrari
  • Gender:Male
  • Location:Greece

Posted 06 January 2012, 20:15

Thank you, chris I know your contrib, sorry but I wanna create my own.

if you have any idea.

in shopping_cart.php page I check

tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

this goto aplication_top.php

case 'update_product'
$cart->remove($HTTP_POST_VARS['products_id'][$i]);

and then this goto include/classes/shopping_cart.php

function remove WHY THIS NOT WORK???

#4 drferrari

  • Community Member
  • 11 posts
  • Real Name:drferrari
  • Gender:Male
  • Location:Greece

Posted 07 January 2012, 21:33

forgot the above posts, it is Lenght * width = square metere value

Look at my my attach files. (and make it work on your oscommerce)

1) product_info-1.php page (FOR ADD FIRST PRODUCTS WITH LENGHT AND WIDTH)-> rename to product_info.php for your first add to cart

2) product_info-2.php page (FOR ADD SECOND PRODUCTS NO LENGHT AND WIDTH only quantity e.g. 10)-> rename to product_info.php for your second add to cart

3) shopping_cart.php

4) includes/application_top.php

5) square-meter5.txt rename to -> square-meter5.js

6) includes/classes/shopping_cart.php
look at :
function update_quantity($products_id, $lenghtValue, $widthValue, $quantity = '', $attributes = '') { 
if you have product A with LENGHT AND WIDTH and product B with NO LENGHT AND WIDTH in your shopping cart and try change quantity of the product B you can't,

if you change the function to:
function update_quantity($products_id, $quantity = '', $lenghtValue, $widthValue, $attributes = '') { 
you can change the quantity BUT you loose LENGHT and WIDTH of your product A

ANY IDEA HOW CAN I FIT IT.

#5 drferrari

  • Community Member
  • 11 posts
  • Real Name:drferrari
  • Gender:Male
  • Location:Greece

Posted 19 January 2012, 14:53

I found it "YEAHHHH", wait for my square meter contrib. thanks all chat friend for advises.

#6 fermoncho1969

  • Community Member
  • 1 posts
  • Real Name:Fernando

Posted 22 January 2012, 10:06

Hi, drferrari.

I'm very interested in your contrib. I'm not an php expert, but it would be fantastic for my carpet shop. Thanks in avance