X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   X-Configurator => with a base Price+base Weight+base etc. (https://forum.x-cart.com/showthread.php?t=18551)

tomazws 12-09-2005 09:10 AM

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 :wink:

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";
}


balinor 02-09-2006 03:52 AM

Moving to Custom Mods

subzero 04-23-2006 04:57 PM

great mod just what i was looking for
tried it and it works great!!! =D>

VmarkJon 11-16-2007 10:17 AM

Re: X-Configurator => with a base Price+base Weight+base etc.
 
I'm using x-cart-4.1.9 gold and I can't find any of this code. When you say, "open up func.php" which func.php do you mean?

intel352 11-18-2007 08:43 PM

Re: X-Configurator => with a base Price+base Weight+base etc.
 
X-Cart 4.1 is greatly different from X-Cart 4.0. You'll need to search files in the include/func/ folder.

fivestar 01-27-2008 07:43 PM

Re: X-Configurator => with a base Price+base Weight+base etc.
 
Has anyone tried this mod in 4.19? I'm attempting to do it but not sure exactly where to start?

Greg

jwiegand 02-20-2008 12:51 PM

Re: X-Configurator => with a base Price+base Weight+base etc.
 
I think there are a number of us that could use this mod rewritten for 4.1.9. I'm looking at it now, and while the code is similar - it's different enough that a little bit more experienced help would be useful :)

Any help?

BodyBalance 06-16-2008 07:40 AM

Re: X-Configurator => with a base Price+base Weight+base etc.
 
Anyone have an update on this?


All times are GMT -8. The time now is 12:46 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.