PHP Function to Clean Data before using in JavaScript or FBJS

Single quotes, double quotes, slashes and all kinds of other junk data will break your application code, especially the js and FBJS dialog boxes for sharing and components if the data is not cleaned properly. Following PHP function will clean your data for such garbage. function cleanData($data) { $cleaned = preg_replace(“/[^A-Za-z0-9\s\.\-\/+\!;\n\t\r]/”,””, $data); $cleaned = preg_replace(“/\s+/”,”…

[osCommerce] Change Currency Selection based on Payment Module on checkout_confirmation page in osCommerce Store

In osCommerce store which has been set up to accept payment using multiple payment modules, there are chances that you might want to accept payments in specific currencies based on payment methods. Not every payment method support all currencies. You can change currency based on payment module selection by adding few lines of code on…

[osCommerce] How To Check if the Customer is Logged in or not in osCommerce Store

While working in osCommerce store, there are many places where you want to show some infromation only to logged in customers, and some thing else to non-logged in users. For this purpose, you need to check tep_session_is_registered(‘customer_id’) variable and show different blocks of content. In the following code, I have put togther an example where…

[AlertPay+osCommerce] Resolve AlertPay Payment Module Error – ap_shipping charges field must be numeric

While setting up AlertPay Payment module in a osCommerce Store, I encountered following error “ap_shippingcharges field must be numeric” during a test purchase. To fix this error, open catalog/includes/modules/payment/alertpay.php Find this: tep_draw_hidden_field(‘ap_shippingcharges’, $order->info[‘shipping_cost’]) . Replace with this: tep_draw_hidden_field(‘ap_shippingcharges’, number_format($order->info[‘shipping_cost’], 2, ‘.’, ”)) . I have also updated the AlertPay contribution on osCommerce website here. Hope…

[Joomla] Resolve Error Installing Joomla Components or Plugins, It was not possible to copy the selected file

If you get following error while installing Joomla components or plugins, It was not possible to copy the selected file. JInstaller::install: Failed to copy file: /var/www/localhost/htdocs/tmp/install_4d621e648af3f/plg_sslredirect/sslredirect.php to /var/www/localhost/htdocs/plugins/system/sslredirect.php Permission Solution You can resolve this by changing permissions (chmod to 777) on following directories in your Joomla website. chmod 777 /tmp chmod 777 /plugins/content chmod 777…