How-To: How to add ZAR support to Classipress 3.0.5.4
Here’s a manual solution to implementing ZAR support for EFT Payments in the Classipress theme version 3.0.5.4. It might even still work in the latest version. Anyone who’s keen, please give it a bash and see.
DISCLAIMER 1: This fix is not elegant or even that simple. If you know your way around PHP you should not have too much difficulty. If you set up your own theme and made some tweaks to it it should be enough to get your values changed.
DISCLAIMER 2: This fix is coded on top of the Classipress theme. When you update your theme, you’re going to have to do all of this again (I did not bother trying to make a child theme, sorry). I do not take any responsibility for this code breaking your site, I’m just sharing what worked for me.
What it entails
What we’re going to do is create a method that we’ll use to effectively replace the Classipress method for calculating currency. This will involve creating a custom functions.php file that we can include in the steps process.
Let’s do it!
Start by creating a new PHP file called
functions.php and save it in the Classipress directory in a folder called
custom-functions. Thus:
/wp-content/themes/classipress/custom-functions/functions.php
Now, paste the following code into it and save it:
PHP Code:
function cp_pos_price_wdh($amount){
$dollar_amounts = array(8,15,75,120,"8.00","15.00","75.00","120.00"); // Change here
$rand_amounts = array(50,100,500,800,50,100,500,800); // Change here
foreach($dollar_amounts as $key=>$val) {
if ($val == $amount) {
return 'R '.$rand_amounts[$key] . ' ($ '.$amount.')'; // This is the output that gets returned.
break;
}
}
}
Now use the two arrays named
dollar_amounts and
rand_amounts to manually set up your conversions.
Important, these must correlate to the
Ad Packages that you’ve already set up in the Theme settings otherwise you won’t get any results back.
Thus, position 0 in the dollar array corresponds to position 0 of the rand array and position 1 in the dollar array corresponds to position 1 in the rand array etc.
Once you’ve done that, start editing some of the theme files:
1. Include your new function
Include your new PHP file at the top of
includes/forms/step-functions.php:
PHP Code:
include_once ('/wp-content/themes/classipress/custom-functions/functions.php');
2. Change amounts on Step 2
Open up includes/forms/step-functions.php and edit/add the following:
- Line 471 – change this code
PHP Code:
<div id="review"><?php if (get_option('cp_charge_ads') == 'yes') { echo cp_pos_price(number_format($postvals['cp_sys_ad_listing_fee'], 2)); } else { echo __('FREE', 'appthemes'); } ?></div>
- To this code
PHP Code:
<div id="review"><?php if (get_option('cp_charge_ads') == 'yes') { echo cp_pos_price_wdh(number_format($postvals['cp_sys_ad_listing_fee'], 2)); } else { echo __('FREE', 'appthemes'); } ?></div>
- And the code on line 508, change it to:
PHP Code:
if (get_option('cp_charge_ads') == 'yes' || isset($postvals['featured_ad'])) echo cp_pos_price_wdh($postvals['cp_sys_total_ad_cost']); else echo __('--');
3. Change amounts on step 3 (Final step)
Open up
includes/gateways/banktransfer/banktransfer.php :
line 28:
PHP Code:
<strong><?php _e('Total Amount:', 'appthemes') ?></strong> <?php echo get_post_meta($post_id, 'cp_sys_total_ad_cost', true); ?> (<?php echo get_option('cp_curr_pay_type'); ?>)<br />
Replace with:
PHP Code:
<strong><?php _e('Total Amount:', 'appthemes') ?></strong> <?php echo cp_pos_price_wdh(get_post_meta($post_id, 'cp_sys_total_ad_cost', true)); ?><br />
And that’s that. You should now notice that for each value a ZAR value is given as well as the USD equivalent (roughly).
DISCLAIMER 3: It is up to you as the site owner to keep the conversion rates up to date. They are based on conversions from Google (Google). The USD price will and should be slightly higher to offset some of the banking costs to get your money out of PayPal.
To do this, you would edit your Ad Package FIRST and then use those values set up there in the functions.php file that we created here.
Last edited by superhero; July 20th, 2011 at 10:03 AM.
Reason: formatting change