Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

I want to get a custom value from customers directly


kulvalcan

Recommended Posts

Hello.

I need to get custom value from customers on each product screen.

Customers can buy product by its length so they should input lenght value they want to buy in textbox instead of selecting value from dropdown menu.

And finally, the length they input will be applied to final price.(basic price + length price)

I tried but still I have no idea how to make it.

Someone can help me?

Link to comment
Share on other sites

Looking at the

 

shopping_cart.php

 

page of the Online Demo, it has a textbox not a dropdown menu. Your store seems to be more elaborate than you need. Whilst looking at the page you can type something like '4.6' into the box, and then click 'Update'. It will be found that the number is rounded down to '4'. So you may will need to do a bit re-coding to accept non-integer values, after deciding how many decimal places to allow.

 

Your 'basic price' is evidently a 'per item' thing, not a 'per order' thing. So we need to glance at

 

function calculate() {
 global $currencies;
 $this->total = 0;
 $this->weight = 0;
 if (!is_array($this->contents)) return 0;
 reset($this->contents);
 while (list($products_id, ) = each($this->contents)) {
 $qty = $this->contents[$products_id]['qty'];
// products price
 $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
 if ($product = tep_db_fetch_array($product_query)) {
	 $prid = $product['products_id'];
	 $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	 $products_price = $product['products_price'];
	 $products_weight = $product['products_weight'];
	 $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	 if (tep_db_num_rows ($specials_query)) {
	 $specials = tep_db_fetch_array($specials_query);
	 $products_price = $specials['specials_new_products_price'];
	 }
	 $this->total += $currencies->calculate_price($products_price, $products_tax, $qty);
	 $this->weight += ($qty * $products_weight);
 }
// attributes price
 if (isset($this->contents[$products_id]['attributes'])) {
	 reset($this->contents[$products_id]['attributes']);
	 while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
	 $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
	 $attribute_price = tep_db_fetch_array($attribute_price_query);
	 if ($attribute_price['price_prefix'] == '+') {
		 $this->total += $currencies->calculate_price($attribute_price['options_values_price'], $products_tax, $qty);
	 } else {
		 $this->total -= $currencies->calculate_price($attribute_price['options_values_price'], $products_tax, $qty);
	 }
	 }
 }
 }
}

 

in

 

includes/classes/shopping_cart.php

 

If the basic price is the same for every one of your products then we can just go to

 

$this->total += $currencies->calculate_price($products_price, $products_tax, $qty);

 

to tack a number on the end

 

$this->total += $currencies->calculate_price($products_price, $products_tax, $qty) + 10;

 

But if they are not all the same then it's a case of making a new column in the products table (probably called 'products_basic') and augmenting

 

$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

 

to pick it out.

 

Some of the values, in your products_weight column, are presumably not kilograms but kilograms per meter.

Link to comment
Share on other sites

You could add a price per unit and the store will calculate the total cost of the units ordered.

 

So a product will be set up with a length/unit as 300mm. A customer will then order 12 so will receive from you a length 300mm x 12 = 3600mm. There is not a need to over complicate things as the store is designed to work like this. You may just need to add into the product description something that states what the maximum length of the product can be. You then supply in multiples of the maximum length plus any odd bits.

 

I am sure that there are some addons that will allow ordering of fractions of a unit if you need to go smaller that your unit price.

 

We sell some electrical wire like this, and it works fine. The wire is priced per metre, and if a customer orders 50 they receive 50 metres of wire in a 50 metre length.

REMEMBER BACKUP, BACKUP AND BACKUP

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...