Hi to you all!
Back in November I setup a CS-Cart for my client( 2.0.8 ). I am hoping that I can fully hand the cart to my client( 2.0.12 ) safe in the knowledge that when she upgrades going forward there will be no issues with styling or changes to its functionality as made back in November. I am particularly nervous at his stage! Obviously I will be backing up databases and files to ensure I can always backtrack from v8 to v12, however I am still nervous with regard to handing the cart 100% to the client and knowing that upgrade will run smoothly. My client is not super technical.
Could anybody advise on the coding changes that I implemented to v2.0.8 below and how I can better implement those changes to ensure they are not overwritten in future upgrades beyond v2.0.12
addons/news_and_email/func.php
Removed red code
Purpose: to remove backslashes that were being added before all links in newsletter
$regex = "/href=([COLOR="Red"]'|\")([/COLOR](?:http|ftp|https):\/\/[\w-\.]+[?]?[-\w:\/?\.\=%&;~\[\]]+)/ie";
and
$replace_regex = "'href=[COLOR="Red"]\[/COLOR]$1$url&link=' . fn_register_link('\$2', $newsletter_id, $campaign_id) . '-' . $newsletter_id . '-' . $campaign_id";
Comment: Am I correct in assuming that this bug has been corrected in upgrade 2.0.9 and so by overwriting there will be no effect?
addons/my_changes/controllers/customer/categories.post.php
Added red code - new file
Purpose: to display subcategories list as a multi column list with images, not a bug just changing styling layout
[COLOR="Red"]
if ($mode == 'view') {
$subcat = $view->get_var('subcategories');
$subcat = fn_get_subcategories($_REQUEST['category_id']);
foreach($subcat as $k => $v) {
$subcat[$k]['main_pair'] = fn_get_image_pairs($v['category_id'], 'category', 'M', true, false);
}
$view->assign('subcategories', $subcat);
}
?>[/COLOR]
Comment: Am I correct in assuming that as this file exists in ‘my_changes’ it will not be overwritten providing ‘My Changes’ addon is active in the backend?
core/templater_plugins/modifier.cart_status_format_price.php
Added red code - new file
Purpose: to override the decimal places reflected in the cart status to 0dp, this not a bug just changing how styled
```php
[COLOR=“Red”]
/**
- Smarty plugin
-
@package Smarty
-
@subpackage plugins
*/
/**
- Smarty plugin
- -------------------------------------------------------------
- Type: modifier
- Name: price
- Purpose: getting formatted price with grouped thousands and
-
decimal separators
- Example: {$price|price:“2”:“.”:“,”}
- -------------------------------------------------------------
/
function smarty_modifier_cart_status_format_price($price, $currency, $span_id, $class = ‘’, $is_secondary = false)
{
$value = fn_format_rate_value($price, $number_type, $currency[‘’], $currency[‘’], $currency[‘thousands_separator’], $currency[‘coefficient’]);
if (!empty($class)) {
$currency[‘symbol’] = ‘’ . $currency[‘symbol’] . ‘’;
}
if (!empty($span_id) && $is_secondary == true) {
$span_id = ‘sec_’ . $span_id;
}
if (!empty($class) || !empty($span_id)) {
$data = array (
‘’,
$value,
‘’,
);
} else {
$data = array($value);
}
if ($currency[‘after’] == ‘Y’) {
array_push($data, ’ ’ . $currency[‘symbol’]);
} else {
array_unshift($data, $currency[‘symbol’]);
}
return implode(‘’, $data);
}
/ vim: set expandtab: */
?>[/COLOR] ```
Comment: Am I right is assuming that as this file is a modifier it will not be overridden by upgrades?
core/fn.common.php
Added/Changed red code
Purpose: to increase the precision of tax and price calculation
return (float)sprintf("%.[COLOR="Red"]4[/COLOR]f", round((double) $price + 0.00000000001, 4));
Purpose: to ensure the figure passed from cs-cart to paypal is correctly rounded to 2 digits(second code block)
```php
[COLOR=“Red”]/**
- ensure paypal price is rounded to 2 digits
*/
function fn_format_price_paypal($price = 0)
{
return sprintf(“%.2f”, round((double) $price + 0.00000000001, 2));
}
[/COLOR] ```
Comment: Concerned as this file will probably be overwritten with each upgrade, how might I get around this issue? The first code block adjustment was recommended in the KBase which is a tad concerning from an upgrade perspective.
payments/paypal.php
Added/Changed red code
Purpose: to add AU format telephone numbers to ensure the format was passed correctly to Paypal
// Telephone Numbers
$_phone = str_replace(array('-','(',')',' ',[COLOR="Red"]'+'[/COLOR]), '',$order_info['phone']);
if ([COLOR="Red"]([/COLOR]strlen($_phone) == 10[COLOR="Red"]) && ($order_info['b_country'] == ('US'))[/COLOR]) {
} elseif ((strlen($_phone) == 11) && ([COLOR="Red"]$order_info['b_country'][/COLOR] == ('[COLOR="Red"]UK[/COLOR]'))) {
[COLOR="Red"] } elseif ((strlen($_phone) == 12) && ($order_info['b_country'] == ('UK'))) {
$_ph_a = '44';
$_ph_b = substr($_phone, 2);
$_ph_c = '';
[/COLOR]
[COLOR="Red"]// AU numbers
} elseif ((strlen($_phone) == 10) && ($order_info['b_country'] == ('AU'))) {
$_ph_a = '61';
$_ph_b = substr($_phone, 1);
$_ph_c = '';
} elseif ((strlen($_phone) == 11) && ($order_info['b_country'] == ('AU'))) {
$_ph_a = '61';
$_ph_b = substr($_phone, 2);
$_ph_c = '';
[/COLOR]
Purpose: to ensure that no shipping value or notes were passed to PayPal to avoid confusion to the payer
[COLOR="Red"]
[/COLOR]
Purpose: to ensure the total cart figure passed from cs-cart to paypal is correctly rounded to 2dp
$v['price'] = fn_format_price_[COLOR="Red"]paypal[/COLOR](($v['subtotal'] - fn_external_discounts($v)) / $v['amount']);
Comments: This file will probably be overwritten by upgrades in the future how can I get around this problem?
skins/
Purpose: I have added a unique skin relevant to the client so the only directories that exist within skins is basic and my customers template.
Comments: Will this be overwritten?
var/skins_repository
Purpose: I deleted removed all skins here except the basic and the customers template as I didnt want the customer to get confused.
Comments: By the looks of upgrades it re-replaces all the skins repository is there a way to avoid this?
I would really love some help to gain confidence so that I can impart that confidence to my client when I finally hand the product to them to administer and keep up with upgrades. Could anybody guide me?
Thanks :o