Posts

Showing posts from October, 2010

[Virtuemart] Customize Order List - adding extra column

In this post, I am going explain on how to add an extra column in Virtuemart Administrator Order List page. (Note that, in this example, I'm going to add a new address_1 column). Note: Please refer to my previous post on " adding search keywords " for the SQL query code for the other fields that you want. Getting Started. In /administrator/components/com_virtuemart/html/order.order_list.php locate this section, around line 27. Then add " address_1 " into the line, as below. //$list .= "first_name, last_name FROM #__{vm}_orders, #__{vm}_order_user_info WHERE "; // This is the modified line. $list .= "first_name, last_name, address_1 FROM #__{vm}_orders, #__{vm}_order_user_info WHERE "; After that, locate this section, as usual and note that " Address_1 " is already the added column. $columns = Array( "#" => "width=\"20\"", "<input type=\"checkbox\" name=\"tog

Virtuemart Add-to-cart not working

Image
Check whether you are using '  (direct input from keyboard) instead of ’  for your product name. For example: Virtuemart potential source of problem :) References : http://forum.virtuemart.net/index.php?action=printpage;topic=26822.0

[Haskell] [Oz] Function that computes the permutation of a list

Mozart Oz Programming Language declare fun {Permutation L} case L of nil then [nil] [] H|T then {FoldR {Map {Permutation T} fun {$ X} % Inser H into all position IntFrom in fun lazy {IntFrom K} K|{IntFrom K+1} end {Map {List.take {IntFrom 0} {List.length X}+1} fun {$ Pos} {FoldR X (fun {$ J K} case K of nil then nil [] S#I then if I \= Pos-1 then {Append [J] S}#(1+I) else {Append [H J] S}#(1+I) end end end) ({List.drop [H] Pos}#0) }.1 end} end } fun {$ X Y} {Append X Y} end nil } end end %{Browse {Permutation [a]}} % shows [[a]] %{Browse {Permutation nil}} % shows [nil] {Browse {Permutation [a b c]}} % shows [[c b a] [c a b] [a c b] % [b c a] [b a c] [a b c]] Haskell Programming Language -- function that computes the permutations of a list -- permutation ["a","b&

[Haskell] [Oz] Oz function that insert element to all possible positions in a list

function that insert X to all possible positions in the list L. Mozart Oz Programming Language declare fun {AllInsert X L} IntFrom in fun lazy {IntFrom K} K|{IntFrom K+1} end {Map {List.take {IntFrom 0} {List.length L}+1} fun {$ Pos} {FoldR L (fun {$ Z Y} case Y of nil then nil [] S#I then if I \= Pos-1 then {Append [Z] S}#(1+I) else {Append [X Z] S}#(1+I) end end end) ({List.drop [X] Pos}#0) }.1 end} end {Browse {AllInsert 10 [a b c d]}} %shows [a b c d 10] [a b c 10 d] %[a b 10 c d] [a 10 b c d] %[10 a b c d]] Haskell Programming Language -- function that inserts an element at all possible positions in a list allInsert :: a -> [a] -> [[a]] allInsert x [] = [[x]] allInsert x xs = map f [0..(length xs)] where f s = insert x s xs -- allInsert "x" ["a","b","c","d","e

[Oz] [Haskell] Function that inserts element to a given position in a list

Below are example code in Oz and Haskell for the function that inserts an element at a given position in a list. The position should be counted from the end of the list. Mozart Oz Programming Language declare fun {Insert A Pos L} {FoldR L (fun {$ X Y} case Y of nil then nil [] S#I then if I \= Pos-1 then {Append [X] S}#(1+I) else {Append [A X] S}#(1+I) end end end) ({List.drop [A] Pos}#0)}.1 end {Browse {Insert 10 0 [a b c d e]}} %shows [a b c d e 10] Haskell Programming Language module Main where insert :: a -> Int -> [a] -> [a] insert x n [] = [] insert x n xs = f ++ [x] ++ drop (length xs - n) xs where f = (take (length xs - n) xs) -- insert "x" 1 ["a","b","c","d","e"] References: http://www.haskell.org/ghc/docs/6.12.1/html/libraries/base/src/Data-List.html#insert http://defowl.blogspot.com/2007/04/coding-in-haskell.html

Credit Card numbers for Testing

While testing, use only the credit card numbers listed here. Other numbers produce an error. Expiration Date must be a valid date in the future (use the mmyy format). Test Credit Card Account Numbers American Express 378282246310005 American Express 371449635398431 American Express Corporate 378734493671000 Australian BankCard 5610591081018250 Diners Club 30569309025904 Diners Club 38520000023237 Discover 6011111111111117 Discover 6011000990139424 JCB 3530111333300000 JCB 3566002020360505 MasterCard 5555555555554444 MasterCard 5105105105105100 Visa 4111111111111111 Visa 4012888888881881 Visa 4222222222222 Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number. Processor-specific Cards Dankort (PBS) 76009244561 Dankort (PBS) 5019717010103742 Switch/Solo (Paymentech) 6331101999990016

[Virtuemart] Customize Order List search keywords

Image
The default Order List search keyword doesn't check for customer's email address, billing addresses, phone numbers, Custom Message... To include all these: In /administrator/components/com_virtuemart/html/order.order_list.php locate this section if (!empty($keyword)) { $q .= "(#__{vm}_orders.order_id LIKE '%$keyword%' "; $q .= "OR #__{vm}_orders.order_status LIKE '%$keyword%' "; $q .= "OR first_name LIKE '%$keyword%' "; $q .= "OR last_name LIKE '%$keyword%' "; $q .= "OR CONCAT(`first_name`, ' ', `last_name`) LIKE '%$keyword%' "; The add the keywords that you wish to include. Below is an example code. The codes are pretty self-explanatory. $list = "SELECT #__{vm}_orders.order_id,order_status, #__{vm}_orders.cdate,#__{vm}_orders.mdate,order_total,order_currency,#__{vm}_orders.user_id,"; $list .= "first_name, last_name

bin/sh^M: bad interpreter: No such file or directory

Tried to install DirectAdmin on Ubuntu just now but encounter the following error. ./setup.sh: /bin/sh^M: bad interpreter: No such file or directory A quick Google search revealed that dos2unix can fix the problem. sudo apt-get install dos2unix Then fix the problem by. This will convert the file to unix format. dos2unix setup.sh Then just execute the file as per normal.

Token StartElement in state Epilog would result in an invalid XML Document

Image
Was trying to create an XML document and kept running into this error. Exception: Thrown: "Token StartElement in state Epilog would result in an invalid XML Document." (System.InvalidOperationException) A System.InvalidOperationException was thrown: "Token StartElement in state Epilog would result in an invalid XML Document." First check on the structure of your XML documents seems there aren't any syntax error. But if you notice the circled error in the above picture, you will realize that the problem is simply because "root" element was not included. So make sure you always have a root element. Attached below are sample code for creating a XML document. namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {             XmlTextWriter textWriter = new XmlTextWriter(D:\\myXmFile.xml, null);             // Opens the document             textWriter.WriteStartDocument();             {