View Single Post
  #1  
Old 12-09-2005, 09:10 AM
 
tomazws tomazws is offline
 

Member
  
Join Date: Jan 2005
Location: Walnut, California
Posts: 16
 

Default X-Configurator => with a base Price+base Weight+base etc.

Got it working, implemented into with all these other changes our client requested for. I'm sorry that I cannot disclose the link of the website.

Here's the basic idea of the changes. I'm not good at writing tutorials.... So for more details, you'd prolly have to figure it out yourself

This sloppy little guide will be applied on X-Cart Gold v.4.0.14.

----------------------------------------

Let's talk about the check out first:

First, we need X-Cart to do shipping calculation on all configurator products (Base product). So, open up func.php, look for the function listed below, and replace the commented out code, with the line of code right below it.

Code:
function func_calculate_shippings($products, $shipping_id, $customer_info, $provider="") { . . . // if ($product["free_shipping"] == "Y" || $product['product_type'] == 'C') if ($product["free_shipping"] == "Y") . . .

Add a base price for the configurator product. Needs to change 2 functions under func.php

Code:
function func_calculate_single($cart, $products, $login, $login_type, $provider_for="") { . . . //$product["pconf_price"] = $product["price"] = max(doubleval($product["options_surcharge"]), 0); $product["pconf_price"] = $product["price"] = $product["price"] + max(doubleval($product["options_surcharge"]), 0); . . .

Code:
function func_products_from_scratch($scratch_products, $membership, $persistent_products) { . . . /* if ($products_array["product_type"] == "C") $products_array["price"] = $products_array["options_surcharge"]; else $products_array["price"] += $products_array["options_surcharge"]; */ $products_array["price"] += $products_array["options_surcharge"]; . . .

Now the Configurator Product has a regular product's price and weight, it'll add up to the total, apply tax, and all other stuff automatically. Please edit all the *.tpl's (example: cart_details.tpl) so that the Configurator Product will also show its price/weight.

But...
what's the point of having a base price and a base weight, when you can't even type them in on our back-end?!?!?!

First, implement all the form fields from skin1/main/product_details.tpl to skin1/modules/Product_Configurator/product_details.tpl... like "price", weight, this that... bla bla bla... so you could at least enter a price and weight to the Configurator Product.

then, we'll need to edit a PHP file so that X-Cart could record the price and weight and other stuff into the database.

Under modules/Product_Configurator/product_modify.php:

X-Cart insert '0' as price for the C-Product. We want OUR own price:
Code:
. . . //db_query("INSERT INTO $sql_tbl[pricing] (productid, quantity, price) VALUES ('$productid', '1', '0')"); //REPLACE THIS LINE db_query("INSERT INTO $sql_tbl[pricing] (productid, quantity, price) VALUES ('$productid', '1', '".abs($price)."')"); //WITH THIS LINE. . . .

X-Cart doesn't update price, doesn't update weight, quantity... etc. But we would like to be able to: (put the following code right under, or right above where X-Cart updates the images. So that X-Cart will also update price and weight and etc.)
Code:
# # Update existing product # db_query("UPDATE $sql_tbl[pricing] SET price='$price' WHERE productid='$productid' AND quantity='1' AND membership='' AND $sql_tbl[pricing].variantid = 0"); if($fields['price'] == 'Y' && $productids) db_query("UPDATE $sql_tbl[pricing] SET price='$price' WHERE quantity='1' AND $sql_tbl[pricing].variantid = 0 AND membership=''".$products_condition);

and then.. replace the following commented out line (the first line) with the junk below:
Code:
. . . //db_query("UPDATE $sql_tbl[products] SET product='$product', descr='$descr', fulldescr='$fulldescr', avail='1', list_price='0.00', weight='0', productcode='$productcode', forsale='$forsale', min_amount='$min_amount' WHERE productid='$productid'"); # Correct the min_amount if (empty($min_amount) or intval($min_amount) == 0) $min_amount = 1; # # Update product data # db_query("UPDATE $sql_tbl[products] SET product='$product', descr='$descr', fulldescr='$fulldescr', avail='$avail', list_price='$list_price', cost='$cost', weight='$weight', productcode='$productcode', forsale='$forsale', distribution='$distribution', free_shipping='$free_shipping', shipping_freight='$shipping_freight', discount_avail='$discount_avail', min_amount='$min_amount', return_time = '$return_time', low_avail_limit='$low_avail_limit', free_tax='$free_tax' WHERE productid='$productid'"); if($image_posted && !empty($image_data)) { db_query("UPDATE $sql_tbl[products] SET image_x='$image_data[image_x]', image_y='$image_data[image_y]' WHERE productid='$productid'"); } db_query("DELETE FROM $sql_tbl[product_taxes] WHERE productid='$productid'"); if($productids && $fields['taxes']) db_query("DELETE FROM $sql_tbl[product_taxes] WHERE productid IN ('".implode("','", array_keys($productids))."')"); if (!empty($taxes) and is_array($taxes)) { foreach ($taxes as $k=>$v) { if (intval($v) > 0) { db_query("REPLACE INTO $sql_tbl[product_taxes] (productid, taxid) VALUES ('$productid', '".intval($v)."')"); if($productids && $fields['taxes']) { foreach($productids as $pid => $v2) db_query("REPLACE INTO $sql_tbl[product_taxes] (productid, taxid) VALUES ('$pid', '".intval($v)."')"); } } } } if ($productids && $fields) { $tmp = array(); foreach($fields as $k => $v) { if(!in_array($k, array("efields", "price", "thumbnail", "categoryid", "categoryids", "taxes"))) { $tmp[] = $k.'="'.$$k.'"'; } } if($tmp) db_query("UPDATE $sql_tbl[products] SET ".implode(", ", $tmp)." WHERE 1".$products_condition); } if ($active_modules["Extra_Fields"]) { include $xcart_dir."/modules/Extra_Fields/extra_fields_modify.php"; }
__________________
-Thomas
Design Range
thomas@designrange.com
http://www.designrange.com
Reply With Quote