Aug 03, 2009 06:30 PM
This is more of a set of modifications rather than an actual module, but the end result is the same.
First thing you’ll need to do is backup your existing site and database. I’d recommend using a test install of Xcart so that nothing in production gets messed up. With that in mind, the first step is to alter the pricing table by using the following alter table command. If you have a different version of MySQL, you might need to tweak this a bit.
ALTER TABLE `xcart_pricing` ADD COLUMN `numpymnts` INTEGER UNSIGNED NOT NULL DEFAULT 1,
ADD COLUMN `paymentprice` DECIMAL(12,2) NOT NULL DEFAULT 0 AFTER `numpymnts`,
ADD COLUMN `sourceproductcode` VARCHAR(255) DEFAULT 0 AFTER `paymentprice`,
ADD COLUMN `sortby` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `sourceproductcode`,
ADD COLUMN `mastervariant` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `sortby`,
ADD COLUMN `price_override` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `mastervariant`,
ADD INDEX `numpymnts`(`numpymnts`),
ADD INDEX `paymentprice`(`paymentprice`),
ADD INDEX `sortby`(`sortby`),
ADD INDEX `sourceproductcode`(`sourceproductcode`),
ADD INDEX `mastervariant`(`mastervariant`),
ADD INDEX `price_override`(`price_override`)
, ENGINE = MyISAM;
The new columns are as follows:
numpyments = number of payments
paymentprice = price the export expects to see (might be one payment or the total)
sourceproductcode = product code (sku) that export expects to see
sortby = the order in which the variants show up on the admin page
mastervariant = overrides the ’starting at’ price
price_override = use this table for the price instead of the orders table for reporting
Next, you’ll need to modify some of the admin template files, such as:
Modify Files:
/skin1/modules/Product_Options/product_variants.tpl - add fields to the variants html table - don’t add the price_override column.
/modules/Product_Options/func.php - edit func_get_product_variants and add in the columns that were added to the product_variants.tpl file
When you submit the variants, the form goes to:
product_modify.php
section=variants
mode = product_variants_modify
productid = [variable]
submode = “data”
geid = “”
Once sumbitted, the code is run in this ELSEIF block in modules/Product_Options/product_variants.php:
} elseif ($mode == ‘product_variants_modify’ && $vs && $submode != ‘prices’) {
In here, you need to edit the $query_price_data array to include the additional fields; for example:
## BB Edit - added additional fields
$query_price_data = array(
"price" => $v['price'],
"variantid" => $k,
"productid" => $productid,
"quantity" => 1,
"membershipid" => 0,
"numpymnts" => $v['numpymnts'],
"paymentprice" => $v['paymentprice'],
"sortby" => $v['sortby'],
"sourceproductcode" => $v['sourceproductcode'],
"mastervariant" => $v['mastervariant']
);
Next, you need to edit the modify options page, otherwise, if you change options, it’ll remove your new field data.
When submitting this form, it passes these variables to product_modify.php:
section=options
mode=product_options_add
classid= your classid
productid = your productid
geid=”"
If you change add[is_modifier] (price modifier = ‘y’, else it’s blank), it rebuilds the variants by calling func_rebuild_variants in modules/Product_Options/func.php
//Rebuild variants: . . . . product_modify.php?productid=18§ion=options&classid=71
In func_rebuild_variants, change the $_product[’prices’] $data variable to:
$data = array(
"productid" => $productid,
"quantity" => $p['quantity'],
"membershipid" => $p['membershipid'],
"variantid" => $variantid,
"price" => $p['price'],
"numpymnts" => $p['numpymnts'],
"paymentprice" => $p['paymentprice'],
"sortby" => $p['sortby'],
"sourceproductcode" => $p['sourceproductcode'],
"mastervariant" => $p['mastervariant']
);
This will keep your data from being lost in the new columns. And that’s it, as far as back end functionality for the multi pay option. Depending on how your templates are set up, you’ll probably want to use the new columns to force the “mastervariant” column to show up in the “starting at” price. Do this by ordering that query by mastervariant in descending order. The rest of the columns really come in handy when you need to see the full price such as in reports, modifying omniture code, and to produce export files where the fulfillment company wants to see the full amount instead of the per payment price.
xcart | data backup | database | mysql | ecommerce
Aug 03, 2009 06:20 PM
I recently redesigned my photography website, The Lens Flare. I had Internet Explorer 7 and Firefox 2 installed, and thus wrote the site to make it work with those browsers. Once I had it working on those 2 browsers, I tried it on IE6 and the template was horribly screwed up. Here, I’ll explain what I had to change to make it look good in the 2 current browsers and IE6.
Apparently, IE6 has a bug people have dubbed the double padding bug or double margin bug. The problem can usually be fixed by using the CSS option: “display:inline” on your DIVs that have the double spacing problem. This fixed most of the spacing issues, but it didn’t fix them all.
To fix the last spacing problem, I had to resort to an Internet Explorer Kludge called conditional comments to include a separate CSS file when IE6 is loaded.
To do this, you put the following code after your other CSS files in your HEAD tag:
<!--[if IE 6]><link rel=”style sheet” href=”ie6.css” type=”text/css” media=”all” /><![endif]-->
This loads the ie6.css file when somebody is using IE6.
The main CSS file has the following directions for the col2 div:
.col2 {
width:338px;
position:relative; float:left;
margin:0px 0px 0px 5px; padding:0px;
display:inline;
}
The ie6.css file overrides col2 with the following directives:
.col2 {
width:338px;
margin:0px; padding:0px;
display:inline;
}
In IE6, floating the div to the left and adding a margin on the left side messed things up. From what I can tell, it started the location of the div in a slightly different place than IE7 and Firefox does and therefore has to be positioned differently to appear in the same place on the screen.
Also, another trick I learned while dealing with IE6’s limitations was a handly CSS tidbit called: “overflow:hidden”.
There are several places in my layout where I have a 2 pixel tall div with a background color to act as a horizontal rule. For example, this gray line:
.gray-line {
position:relative;
width:99%;
height:2px;
background-color:#ddd;
margin:0px; padding:0px;
overflow:hidden;
}
However, without the overflow:hidden aspect, IE6 renders a line about 5-8 pixels tall.
Lastly, “background-repeat: no-repeat” solved one last IE6 problem. Since it seems to use different heights for things, in places where I’m using a background image, the image would start to repeat itself again for about 2-3 pixels. Setting this directive on those areas solved that problem. Combine that with overflow:hidden and we’re good to go.
css | browsers | web site format
Aug 03, 2009 06:12 PM
Xcart is a fairly popular e-commerce shopping cart program, and one of the add-on modules that you can buy from a third party company is called CDSEO. This rewrites all of the links to be SEF using a folder-style syntax instead of the regular ?variable=value syntax.
However, it causes some problems with X-Cart. One such problem is the Review Product form on the product detail page (product.php).
To fix this bug, you need to add hidden fields to the form instead of having them inside the form’s “action”.
In other words, change:
<form method=”post” action=”/product.php?mode=review&productid={$product.productid}” id=”reviewform”>
To:
<form method=”post” action=”/product.php?productid={$product.productid}” id=”reviewform” method=”post”>
<input type=”hidden” name=”productid” value=’{$product.productid}’ />
<input type=”hidden” name=”mode” value=”review” />
Next, you’ll need to edit vote.php at the document root of your Xcart install and add a slash at the beginning of the link.
So change:
func_header_location(”product.php?productid=$productid”);
to:
func_header_location(”/product.php?productid=$productid”);
This is because the CDSEO module creates a pseudo-directory and thus your browser thinks that it’s in that folder and tries to redirect you to the wrong path.
Aug 03, 2009 06:06 PM
The idea behind using a service like RightScale in a cloud hosting service like Amazon’s EC2 is that you write a small program to install everything needed on your server. Because of this, you can dynamically turn servers on and off depending on your current traffic.
Where it gets difficult is when you need to install something that requires user input such as when signing a GPG key.
To get around this, you’ll need to come up with a solution that will allow you do finish the task without using user input.
In the example of signing GPG keys, instead I use the –always-trust parameter like this:
gpg –always-trust -ear ‘username’ test.txt
This allows me to encrypt a file in a script without having to answer the Yes/No question of whether I really want to encrypt it or not.
Normally, I would sign the key to avoid this question, but signing the key requires several questions to be answered and I’ve yet to find a way to script their answers.
rightscale | amazon hosting | gpg keys
Aug 03, 2009 06:03 PM
I noticed that one of my servers was using quite a bit more of its CPU resources than normal, yet my Analytics software wasn’t showing a spike in traffic. I have a rather large Apache access_log file, and I wanted to see how many times a particular bot scraped my web pages. Looking through it by hand isn’t practical since the log is over 1GB in size.
Instead, what I did was this simple grep command:
grep -c “myregex” access_log
In the quotes, I put the real string that I was searching for. The c flag refers to “Count”, which returns the number of times that regular expression occurs in the file.
In this case, the scraping program that I thought was the culprit had downloaded less than 100 web pages, but the true culprit had downloaded many more. It was using a browser’s User Agent so it’s either a really active visitor, a browser plugin, or a spider spoofing a real browser. To resolve this, I used IPTables to block their IP address. Problem solved.
grep | programming | strings | counting
Visit www.Vauntium.com for more information.