X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   If, elseif, else... suggestion please? (https://forum.x-cart.com/showthread.php?t=11529)

x-online 01-17-2005 08:27 PM

If, elseif, else... suggestion please?
 
Hi, somehow i got confused half way thru the codes...

here is what i wanted it to work (include/history_order.php)
Code:

if ($mode == "invoice" or $mode == "invoice_no_cc" or $mode == "label") {
        header("Content-Type: text/html");
        header("Content-Disposition: inline; filename=invoice.txt");

        $orders = explode(",", $orderid);

        if ($orders) {
                $orders_data = array();
                foreach ($orders as $orderid) {
                        $order_data = func_order_data($orderid);

                        #
                        # Security check if order owned by another customer
                        #
                        if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) {
                                func_header_location("error_message.php?access_denied&id=34");
                        }

                        $order = $order_data["order"];
                        $customer = $order_data["userinfo"];
                        $products = func_translate_products($order_data["products"], ($userinfo['language']?$userinfo['language']:$config['default_customer_language']));
                        $giftcerts = $order_data["giftcerts"];
                        $orders_data[] = array ("order" => $order, "customer" => $customer, "products" => $products, "giftcerts" => $giftcerts);
                }

                $smarty->assign("orders_data", $orders_data);

                $_tmp_smarty_debug = $smarty->debugging;
                $smarty->debugging = false;

                if ($mode == "invoice") {
                        if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
                                $smarty->assign("show_order_details", "Y");
                        func_display("main/order_invoice_print.tpl",$smarty);
                } elseif ($mode == "invoice_no_cc")
                                ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
                                $smarty->assign("show_order_details", "Y");
                        func_display("main/order_invoice_no_cc_print.tpl",$smarty);
                } elseif ($mode == "label")
                        func_display("main/order_labels_print.tpl",$smarty);
               
                $smarty->debugging = $_tmp_smarty_debug;
        }

        exit;


This is the area i stuffed up:
if ($mode == "invoice") {
if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
$smarty->assign("show_order_details", "Y");
func_display("main/order_invoice_print.tpl",$smarty);
} elseif ($mode == "invoice_no_cc")
($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
$smarty->assign("show_order_details", "Y");
func_display("main/order_invoice_no_cc_print.tpl",$smarty);
} elseif ($mode == "label")
func_display("main/order_labels_print.tpl",$smarty);


I can't make it works... right now my code is only this:
Code:

                if ($mode == "invoice") {
                        if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
                                $smarty->assign("show_order_details", "Y");
                        func_display("main/order_invoice_print.tpl",$smarty);
                } elseif ($mode == "invoice_no_cc")
                        func_display("main/order_invoice_no_cc_print.tpl",$smarty);


Any idea please?

shan 01-18-2005 04:12 AM

post what you want it to do and ill see whats what

x-online 01-18-2005 02:40 PM

Thanks...
 
Hi sorry for confused message at the top..
what i tried to do is...
in order > click on the ID to go to the details >
there is a "print invoice" button.
I actually made 2 print invoice buttons there.
One with CC and one without CC in it.

So... i then cut the 'label' section out for now as i can't make it 3 statements like eg. if not A go B if not B go C etc.
i stucked with 2 statement (if not A go B if not B toughluck.... )


Here the current file (include/history_order.php):
Code:

<?php
/*****************************************************************************\

#
# $Id: history_order.php,v 1.22.2.5 2004/11/01 11:41:13 svowl Exp $
#
# Collect infos about ordered products
#

if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }

if (empty($mode)) $mode = "";

if ($mode == "invoice" or $mode == "invoice_no_cc" or $mode == "label") {
        header("Content-Type: text/html");
        header("Content-Disposition: inline; filename=invoice.txt");

        $orders = explode(",", $orderid);

        if ($orders) {
                $orders_data = array();
                foreach ($orders as $orderid) {
                        $order_data = func_order_data($orderid);

                        #
                        # Security check if order owned by another customer
                        #
                        if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) {
                                func_header_location("error_message.php?access_denied&id=34");
                        }

                        $order = $order_data["order"];
                        $customer = $order_data["userinfo"];
                        $products = func_translate_products($order_data["products"], ($userinfo['language']?$userinfo['language']:$config['default_customer_language']));
                        $giftcerts = $order_data["giftcerts"];
                        $orders_data[] = array ("order" => $order, "customer" => $customer, "products" => $products, "giftcerts" => $giftcerts);
                }

                $smarty->assign("orders_data", $orders_data);

                $_tmp_smarty_debug = $smarty->debugging;
                $smarty->debugging = false;

                if ($mode == "invoice") {
                        if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
                                $smarty->assign("show_order_details", "Y");
                        func_display("main/order_invoice_print.tpl",$smarty);
                } elseif ($mode == "invoice_no_cc")
                        func_display("main/order_invoice_no_cc_print.tpl",$smarty);
               
                $smarty->debugging = $_tmp_smarty_debug;
        }

        exit;
} else {
        $order_data = func_order_data($orderid);
        #
        # Security check if order owned by another customer
        #
        if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) {
                func_header_location("error_message.php?access_denied&id=35");
        }

        $smarty->assign("order", $order_data["order"]);
        $smarty->assign("customer", $order_data["userinfo"]);
        $order_data["products"] = func_translate_products($order_data["products"], ($order_data["userinfo"]['language']?$order_data["userinfo"]['language']:$config['default_customer_language']));
        $smarty->assign("products", $order_data["products"]);
        $smarty->assign("giftcerts", $order_data["giftcerts"]);
        if ($order_data) {
                $owner_condition = "";
                if ($current_area == "C")
                        $owner_condition = " AND $sql_tbl[orders].login='".$login."'";
                elseif ($current_area == "P" && !$single_mode ) {
                        $owner_condition = " AND $sql_tbl[order_details].provider='".$login."'";
                }
                # find next
                $tmp = func_query_first("SELECT $sql_tbl[orders].orderid FROM $sql_tbl[orders], $sql_tbl[order_details] WHERE $sql_tbl[orders].orderid>'".$orderid."' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid $owner_condition ORDER BY $sql_tbl[orders].orderid ASC LIMIT 1");
                if (!empty($tmp["orderid"]))
                        $smarty->assign("orderid_next", $tmp["orderid"]);
                # find prev
                $tmp = func_query_first("SELECT $sql_tbl[orders].orderid FROM $sql_tbl[orders], $sql_tbl[order_details] WHERE $sql_tbl[orders].orderid<'".$orderid."' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid $owner_condition ORDER BY $sql_tbl[orders].orderid DESC LIMIT 1");
                if (!empty($tmp["orderid"]))
                        $smarty->assign("orderid_prev", $tmp["orderid"]);
        }
}

$location[] = array(func_get_langvar_by_name("lbl_orders_management"), "orders.php");
$location[] = array(func_get_langvar_by_name("lbl_order_details_label"), "");

if(!empty($active_modules['RMA'])) {
    include $xcart_dir."/modules/RMA/add_returns.php";
}

if(!empty($active_modules['Anti_Fraud'])) {
    include $xcart_dir."/modules/Anti_Fraud/order.php";
}

?>


The original file is:
Code:

<?php
/*****************************************************************************\

\*****************************************************************************/

#
# $Id: history_order.php,v 1.22.2.5 2004/11/01 11:41:13 svowl Exp $
#
# Collect infos about ordered products
#

if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }

if (empty($mode)) $mode = "";

if ($mode == "invoice" or $mode == "invoice_no_cc" or $mode == "label") {
        header("Content-Type: text/html");
        header("Content-Disposition: inline; filename=invoice.txt");

        $orders = explode(",", $orderid);

        if ($orders) {
                $orders_data = array();
                foreach ($orders as $orderid) {
                        $order_data = func_order_data($orderid);

                        #
                        # Security check if order owned by another customer
                        #
                        if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) {
                                func_header_location("error_message.php?access_denied&id=34");
                        }

                        $order = $order_data["order"];
                        $customer = $order_data["userinfo"];
                        $products = func_translate_products($order_data["products"], ($userinfo['language']?$userinfo['language']:$config['default_customer_language']));
                        $giftcerts = $order_data["giftcerts"];
                        $orders_data[] = array ("order" => $order, "customer" => $customer, "products" => $products, "giftcerts" => $giftcerts);
                }

                $smarty->assign("orders_data", $orders_data);

                $_tmp_smarty_debug = $smarty->debugging;
                $smarty->debugging = false;

                if ($mode == "invoice") {
                        if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
                                $smarty->assign("show_order_details", "Y");
                        func_display("main/order_invoice_print.tpl",$smarty);
                } elseif ($mode == "label")
                        func_display("main/order_labels_print.tpl",$smarty);

                $smarty->debugging = $_tmp_smarty_debug;
        }

        exit;
} else {
        $order_data = func_order_data($orderid);
        #
        # Security check if order owned by another customer
        #
        if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) {
                func_header_location("error_message.php?access_denied&id=35");
        }

        $smarty->assign("order", $order_data["order"]);
        $smarty->assign("customer", $order_data["userinfo"]);
        $order_data["products"] = func_translate_products($order_data["products"], ($order_data["userinfo"]['language']?$order_data["userinfo"]['language']:$config['default_customer_language']));
        $smarty->assign("products", $order_data["products"]);
        $smarty->assign("giftcerts", $order_data["giftcerts"]);
        if ($order_data) {
                $owner_condition = "";
                if ($current_area == "C")
                        $owner_condition = " AND $sql_tbl[orders].login='".$login."'";
                elseif ($current_area == "P" && !$single_mode ) {
                        $owner_condition = " AND $sql_tbl[order_details].provider='".$login."'";
                }
                # find next
                $tmp = func_query_first("SELECT $sql_tbl[orders].orderid FROM $sql_tbl[orders], $sql_tbl[order_details] WHERE $sql_tbl[orders].orderid>'".$orderid."' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid $owner_condition ORDER BY $sql_tbl[orders].orderid ASC LIMIT 1");
                if (!empty($tmp["orderid"]))
                        $smarty->assign("orderid_next", $tmp["orderid"]);
                # find prev
                $tmp = func_query_first("SELECT $sql_tbl[orders].orderid FROM $sql_tbl[orders], $sql_tbl[order_details] WHERE $sql_tbl[orders].orderid<'".$orderid."' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid $owner_condition ORDER BY $sql_tbl[orders].orderid DESC LIMIT 1");
                if (!empty($tmp["orderid"]))
                        $smarty->assign("orderid_prev", $tmp["orderid"]);
        }
}

$location[] = array(func_get_langvar_by_name("lbl_orders_management"), "orders.php");
$location[] = array(func_get_langvar_by_name("lbl_order_details_label"), "");

if(!empty($active_modules['RMA'])) {
    include $xcart_dir."/modules/RMA/add_returns.php";
}

if(!empty($active_modules['Anti_Fraud'])) {
    include $xcart_dir."/modules/Anti_Fraud/order.php";
}

?>


The different between the two are:
- added
Code:

} elseif ($mode == "invoice_no_cc")
func_display("main/order_invoice_no_cc_print.tpl",$smarty)

- delete
Code:

} elseif ($mode == "label")
func_display("main/order_labels_print.tpl",$smarty);

because i don't know how to have 3 statements (eg. if, elseif, else)

Can someone tell me how to put these 3 statements together?
Code:

if ($mode == "invoice") {
if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
$smarty->assign("show_order_details", "Y");
func_display("main/order_invoice_print.tpl",$smarty);
} elseif ($mode == "label")
func_display("main/order_labels_print.tpl",$smarty);
} elseif ($mode == "invoice_no_cc")
func_display("main/order_invoice_no_cc_print.tpl",$smarty);


shan 01-19-2005 05:45 AM

ive done something similar in the past but like this

create an extra button to print your invoice and add an extra var

ie - orders.php?orderid=blah&showcc=Y

then on the invoice wrap the cc code part in this

Code:

{if $smarty.get.showwcc eq "Y"}
cc details
{/if}


this is a very basic example and the button code is made up but should give you an idea of how to achieve it

x-online 01-19-2005 06:03 AM

Thanks
 
Thanks Heaps Shan,

As the code for both invoice and no invoice's buttons are already in place and functioning.. Can i use the code i put in earlier but with the label?

I am not expert with php yet so i dont't know how to add the -var you was talking about.

Thank you for your idea tho.

Once this mod done i will post the complete 'how to' for people to use them

shan 01-19-2005 06:07 AM

you can even wrap the cc code in smarty that checks to see if the user is an admin user rather then a customer and show it that way


All times are GMT -8. The time now is 01:43 PM.

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