Opencart PO BOX Validation

If you are wanting to stop people from registering with PO Box based addresses in Opencart 1.5.x then you need to make some modifications to a few key files. The process is very straight forward and should not take long to complete.

Register to read more...

RSMail prevent spamming sign ups

Preventing spam sign ups on RSMail can only be done using captcha. There is no actual backup solution if you do not wish to use the RSMail module without captcha. The most common thing with spammers is that they usually spam from one IP not multiples. To prevent them from spamming I have developed a simple IP checker. RSMail has a field from storing IP's in the Joomla Database. The solution I have developed simply checks to see if the person submitting the information has already submitted an email address. While I realise this is probably a bad solution for those who are using their office connection to sign up I am not going to even cater for those people. Use your home internet or mobile phones data plan.

Register to read more...

CSS Parent Selector Conundrum

While working on a website for a client just a couple weeks back I found an issue where I wanted to make it easier for the client to add and edit images in a particular module with particular attributes to have particular formatting / styling from CSS applied to it. While the first thought was keep it simple I soon came to the realisation that the issue is a lot more complex than first thought.

Register to read more...

Custom fonts in websites

If you are wanting to use custom fonts in websites this is possible by using the following code:


@font-face {
    font-family: fontname;
    src: url('../fonts/fontname.ttf');
}

Keep in mind that good old Internet Explorer fails the test when using the above code so you have to convert the fonts to another format (EOF) and then create a custom css file for IE which contains the following:

@font-face {
    font-family: fontname;
    src: url('../fonts/fontname.eot');
}

Once you have that you can then start referencing the font name in your CSS. This is a really cool feature but not all browsers support this as yet. Give it a go and I am sure you will be most impressed with the outcome.

Refine Product Search By Price Range and Brand - Virtuemart

In shop_browse_queries.php At line 44 insert //filter price by product range $pricer1 = $vmInputFilter->safeSQL( urldecode(vmGet( $_REQUEST, 'product_price', null ))); if ($pricer1 !=0) {    $where_clause[] = "product_price <= " . $pricer1 . ".00000";}    //end filter price by product range Replace lines 81 - 90 withif( $category_id ) {    if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {        $where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;    //MODIFIED FOR FILTER MANUFACTORER     //} elseif( empty( $keyword ) && empty( $manufacturer_id )) {    } elseif( empty( $keyword )) {    //END MODIFIED FOR FILTER MANUFACTORER         $where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;    }} ------------------------------------------------------------------------------------------------ In shop.browse.php At Line 39 insert //filter for product price$pricer = $vmInputFilter->safeSQL( urldecode(vmGet( $_REQUEST, 'product_price', null )));//filter for product price At Line 245 insert  //CHANGES FOR MANUFACTORER FILTER        $orderby_form = $tpl->fetch( 'browse/includes/browse_filterbymf.tpl.php' );        $tpl->set( 'filterby_mf', $orderby_form );                //END CHANGES FOR MANUFACTORER FILTER         Replace lines 150 - 255 with else {       $tpl->set( 'orderby_form', '' );//CHANGES FOR MANUFACTORER FILTER    $tpl->set( 'filterby_mf', '' );//END CHANGES FOR MANUFACTORER FILTER} ---------------------------------------------------------------------------------------------- create file called browse_filterbymf.tpl.php and place in browse/includes/ folder Insert the following code in to the file <?phpif (!defined('_VALID_MOS') && !defined('_JEXEC'))    die('Direct Access to ' . basename(__FILE__) . ' is not allowed.');mm_showMyFileName(__FILE__);?> <?phpif (sizeof($VM_BROWSE_FILTERBY_MF) < 2) {    // return;}?><p id="manufacturerSorting"><?php echo "Manufacturer" ?>: <select class="inputbox" name="manufacturer_id" onchange="order.submit()">    <option value="product_list" >_('PHPSHOP_SELECT') ?></option>    <?php    $query = "SELECT distinct a.manufacturer_id,a.mf_name FROM #__{vm}_manufacturer AS a ";    if (!empty($category_id)) {        $query .= ", #__{vm}_product_category_xref AS d, "                . " #__{vm}_product AS b, "                . " #__{vm}_product_mf_xref AS c "                . " WHERE d.category_id='$category_id'"                . " AND d.product_id = b.product_id "                . " AND b.product_id = c.product_id AND c.manufacturer_id = a.manufacturer_id ";    }    $query .= "ORDER BY mf_name ASC";    $db = new ps_DB;    $db->query($query);     $res = $db->record;     foreach ($res as $manufacturer) {        $selected = '';        if (@$_REQUEST['manufacturer_id'] == $manufacturer->manufacturer_id) {            $selected = 'selected="selected"';        }        echo "<option value=\"" . $manufacturer->manufacturer_id . "\" $selected>" . $manufacturer->mf_name . "</option>\n";    }    ?></select></p><p id="categorySorting"><?php echo "Price" ?>:     <select class="inputbox" name="product_price" onchange="order.submit()">        <option value="">_('PHPSHOP_SELECT') ?></option>        <option value="20">Under $20</option>        <option value="50">Under $50</option>        <option value="100">Under $100</option></select></p>

Show Members Pricing - Virtuemart

Shop.BrowseInsert below line - if(_show_prices = '1' && $auth['show_prices']) { //            $product_price = $ps_product->show_price( $db_browse->f("product_id") );    // DUALPRICE MODIFICATION BEGINS             if ($auth["shopper_group_id"] == '7')            {                $product_price_normal = $ps_product->show_price( $db_browse->f("product_id"), false, 5 );                $product_price_member = $ps_product->show_price( $db_browse->f("product_id"), false, 7 );            }            else            {                $product_price_member = $ps_product->show_price( $db_browse->f("product_id"), false, 7 );                $product_price_normal = $ps_product->show_price( $db_browse->f("product_id"), false, 5 );            }                $product_price =  '<img src="images/tackle-rat-sml.png" style="float:left;padding-left: 22px;position:absolute;z-index:1;" border="0" /><span style="color:#fff;float:left;position:absolute;padding:22px 0 0 35px;z-index:2;">' . $product_price_member . '</span><br class="clear"/><span style="float:left;position:absolute;padding:40px 0px 0px;z-index:2;"> RRP ' .$product_price_normal;     // DUALPRICE MODIFICATION ENDS ------------------------------------------    ps_product.php Insert below line -      * @param boolean $check_multiple_prices Check if the product has more than one price for that shopper group? and above lines -                         // Get the product_parent_id for this product/item            $product_parent_id = $this->get_field($product_id, "product_parent_id"); // DUALPRICE MODIFICATION BEGINS     function get_price($product_id, $check_multiple_prices=false, $overrideShopperGroup='' ) {         if( empty( $product_id)) return array();         $auth = $_SESSION['auth'];         $cart = $_SESSION['cart'];         if( empty( $GLOBALS['product_info'][$product_id]['price'] )         || !empty($GLOBALS['product_info'][$product_id]['price']["product_has_multiple_prices"])         || $check_multiple_prices) {             $db = new ps_DB;             $vendor_id = $this->get_vendor_id($product_id);             if( $overrideShopperGroup === '') {                 $shopper_group_id = $auth["shopper_group_id"];                 $shopper_group_discount = $auth["shopper_group_discount"];             }             else {                 $shopper_group_id = $overrideShopperGroup;                 $shopper_group_discount = 0;             }             // ps_shopper_group::makeDefaultShopperGroupInfo();     // DUALPRICE MODIFICATION ENDS         Insert below line -      * @param boolean $hide_tax Wether to show the text "(including X.X% tax)" or not and above line -                 $tpl->set( 'base_price_info', $base_price_info ); // DUALPRICE MODIFICATION BEGINS    function show_price( $product_id, $hide_tax = false, $shopper_group="") {         global $VM_LANG, $CURRENCY_DISPLAY,$vendor_mail;         $auth = $_SESSION['auth'];         //echo "Show Price :".$product_id."+".$hide_tax."+".$shopper_group";         $tpl = new $GLOBALS['VM_THEMECLASS']();                 $product_name = htmlentities( $this->get_field($product_id, 'product_name'), ENT_QUOTES );         $tpl->set( 'product_id', $product_id );         $tpl->set( 'product_name', $product_name );         $tpl->set( 'vendor_mail', $vendor_mail );         $discount_info = $base_price = array();         $text_including_tax = '';         if( $auth['show_prices'] ) {             // Get the DISCOUNT AMOUNT             $discount_info = $this->get_discount( $product_id );             if( !$discount_info["is_percent"] && $discount_info["amount"] != 0 ) {                 $discount_info["amount"] = $GLOBALS['CURRENCY']->convert($discount_info["amount"]);             }             // Get the Price according to the quantity in the Cart             $price_info = $this->get_price( $product_id, false, $shopper_group );             $tpl->set( 'price_info', $price_info );             // Get the Base Price of the Product             $base_price_info = $this->get_price($product_id, true, $shopper_group );     // DUALPRICE MODIFICATION ENDS -----------------------------------------------------shop.product_details Insert below lines -     else {        $product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE'). ": </strong>";    } and above lines -    }else {    $product_price_lbl = "";    $product_price = "";}     //$product_price = $ps_product->show_price( $product_id );        // DUALPRICE MODIFICATION BEGINS     if ($auth["shopper_group_id"] == '7')    {        $product_price_normal = $ps_product->show_price( $product_id, false, 5 );        $product_price_member = $ps_product->show_price( $product_id, false, 7 );    }    else    {        $product_price_member = $ps_product->show_price( $product_id, false, 7 );        $product_price_normal = $ps_product->show_price( $product_id, false, 5 );    }         $product_price = $product_price_normal.' Price '.$product_price_member;     // DUALPRICE MODIFICATION ENDS      

Video as extra product file

In Flypage.tpl.php add the following code to top of page: // filename filter$product_id = $vmInputFilter->safeSQL( urldecode(vmGet( $_REQUEST, 'product_id', null ))); $db = new ps_DB; $q = "SELECT * FROM `jos_vm_product_files` WHERE `file_product_id` = " .$product_id . " AND `file_extension` = 'flv'";$db->query($q);$row = $db->loadObject();$filed = $row->file_name; // filename filter Insert the following code where you want video to load on flypage: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="480" height="270" id="player1" name="player1" src="<?php echo URL . "media/player/"?>player.swf" width="480" height="270"><param name="movie" value="<?php echo URL . "media/player/"?>/player.swf"><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="flashvars" value="file=&autostart=false&image=<?php echo URL . "components/com_virtuemart/shop_image/product/" . $product_full_image ?>"><embed id="player1" name="player1" src="<?php echo URL . "media/player/"?>player.swf" width="480" height="270" allowscriptaccess="always" allowfullscreen="true" flashvars="file=&autostart=false&image=<?php echo URL . "components/com_virtuemart/shop_image/product/" . $product_full_image ?>" /></object>------------------------------------------------------------- ------------------------------------------------------------- Install Player as attached: upload folder /player/ folder to /media/ on the server

Store and Display Customer Purchase Order Numbers

in checkout.thankyou.tpl.php under the line "_('PHPSHOP_THANKYOU_SUCCESS')?><br />"   <?php $precustomer_note = $dbo->f('customer_note');$prelength = strlen($precustomer_note);$firstpre = strtok($precustomer_note, ":");$firstprelen = strlen($firstpre);$firstprelen++;$charcount = $prelength - $firstprelen;$custom_note = substr($precustomer_note,$firstprelen,$charcount); if ($custom_note !="") {  echo "<span style='color:#ff0000;'><strong>Your Purchase Order Number:</strong></span> " . $custom_note;   } ?>-----------------------------------------------------------------------  in the checkout.thankyou.php under /** retrieve order & payment info **/ /** Retrieve Customer Notes **/$qr = "SELECT customer_note FROM #__{vm}_orders ";$qr .= "WHERE order_id='".$order_id."'";$dbo = new ps_DB;$dbo->query($qr); then under $tpl->set ('db', $db); $tpl->set( 'dbo', $dbo ); ----------------------------------------------------------------------- in the ps_checkout.php under // Collect all fields and values to store them! $pon = $d['pon']; if ($pon != "" ) { $cus_note_full = htmlspecialchars(strip_tags($d['customer_note']), ENT_QUOTES ) . ' <strong>Your Purchase Order Number: ' . $pon . '</strong>'; } else { $cus_note_full = htmlspecialchars(strip_tags($d['customer_note']), ENT_QUOTES ); } and in the $fields = array( change line 'customer_note' => to             'customer_note' => $cus_note_full,            ----------------------------------------------------------------------- in the get_final_confirmation.tpl.php above "please note" add <br /> <span style="color:#ff0000;"><strong>Your Purchase Order Number:</strong></span> <input type="text" name="pon" class="inputbox" /><br />

CSS for footer full width of screen

Getting a footer to go the full width of a screen is a painful exercise if you have never done it or have only done it a few times. After doing a lot of searching on the internet for a div and css solution followed by 2 hours of playing around I have found one that works in all browsers including Internet Explorer, FireFox and Safari. It is CSS 2.0 compliant code so it may not work on older browsers.

Register to read more...