WordpressWordpress admin 13 June, 2011 - 11:36
WordPress adding multiple currency support to the Simple Paypal Shopping Cart pluginWordPress adding multiple currency support to the Simple Paypal Shopping Cart plugin admin 24 April, 2011 - 17:39
Building on the extreme simplicity and ease of use given by Tips and tricks HQ I needed to add support for multiple currencies for checkout and display.
The approach taken is to extend the plugin to have an extra layer that simply converts the default currency into an alternative currency for display and payments (when required).
The rates are automatically taken from the ECB (http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml) every 24 hours and cached.
Changes to support multi currency.
Modified the handling of the title to suppress multiple display of the title and to allow merging of the two widgets into the sidebar to allow the currency selection widget to appear as part of the cart widget.
The amounts always remain in the default currency on the pages and in the cart. The amount requested from paypal can either be in the selected currency or the default currency depending on the configuration option.
The currency conversion is for display, the prices stored in the original posts are unchanged. However to make things more fluid for the customer using an alternative currency there is an option to allow the amount requested for payment from PayPal to be specified in the currency selected by the customer.
When this option is selected it will have the spread applied to it before requesting from PayPal.
When this option is not in use the amounts requested from PayPal will be in the default currency and the customer will pay for the currency conversion.
Exchange rate spreads are used by currency changers such as paypal, your bank, and bureau de change to make a small percentage profit on the exchange of currency by adjusting the rates upwards or downwards in their favour.
To allow the site owner to cover this adjustment I have provided a similar facility in the plugin to allow the conversion used to be adjusted in a similar manner.
Automatic rate updates.
To keep with the spirit of the original plugin the exchange rates are automatically collected, every 24hr from the ECB. This is not configurable and will happen behind the scenes using the rates published by the ECB.
Currency symbols are used when available, when not available the currency code will be used.
To cater for the display of the price in different currencies it is necessary to add the showprice: option to the [wp_cart:] shortcode. This is output unstyled into a div with the class wp-cart-item-price to allow styling.
The multiple currency extension has various configuration options;
Convert currencies locally and request payment in selected currency from Paypal
This option will convert the currencies when requesting payment from Paypal. If this is not selected then the amount requested from PayPal will be in the base (default) currency.
Using this option allows specification of a spread when requesting payments from Paypal.
Currency exchange rate spread %
This allows an extra percentage to be applied to amounts converted from the base currency. This can be used to offset the spread (i.e. charges) applied by Paypal to currency conversion. Paypal allows accounts to be have multi-currency sub-account balances.
Show Currency Selection in Shopping Cart
When set the currency selection will be shown in the shopping cart above the Paypal button. When using the Currency Selector widget directly above the shopping cart widget it is possible to merge these by an automatic facility that will hide the tities.
Currency Selector Title
This will be shown as the title of the widget. If blank the main title of the shopping cart will be used.
Currency Selector List Prompt
Prompt to display in front of the drop down currency selection list. This may be blank.
List of available currencies that are to be shown in the drop down list. The currency symbols are built into the plugin and should be automatically displayed when known.
Screenshot of the configuration.
Below is the new area of the configuration; the existing area is dimmed to highlight the changes as described above:
WordPress plugin to show jcarousel of images from postsWordPress plugin to show jcarousel of images from posts admin 4 June, 2011 - 17:03
arousel of Post images is a fully integrated jcarousel Image Gallery plugin for WordPress to allow quick and easy galleries built from the iamges attached to posts. Built using the excellent JQuery Carousel
The images can be selected based on post ID, or from all images attached to posts. The default is to select 10 random images from all posts.
You can specify a post as an argument to the shortcode, or let the plugin pull a random selection of images from the posts, by default in random order.
- Install & Activate the plugin
- Use the shortcode in your posts or pages where you want a gallery
- Go to your post/page an enter the shortcode ‘[carousel-of-post-images imagesize=small visible=2 count=15]’
- or add to a PHP file in your template: show_wp_copi_carousel($args)
Use the shortcode to display a random selection of images from the posts on your site.
CSS is used to set the sizing of the Carousel areas.
Show a carousel containing 15 images – using the small size from the attachments. The sizing of the div will come from the CSS
[carousel-of-post-images imagesize=small count=15]
if (function_exists( "show_wp_copi_carousel" )) echo show_wp_copi_carousel(array( 'div' => 'mycarousel', 'size' => '30', 'imagesize' => 'thumbnail')); else echo "Please install and activate plugin carousel-of-post-images";?>
Defining the number of visible items
This needs explaining because it can appear confusing; the following is taken from the JCarousel docs.
You simply define the number of visible items by defining the width (or height) with the class .jcarousel-clip (or the more distinct .jcarousel-clip-horizontal and .jcarousel-clip-vertical classes) in your skin stylesheet.
This offers a lot of flexibility, because you can define the width in pixel for a fixed carousel or in percent for a flexible carousel (This example shows a carousel with a clip width in percent, resize the browser to see it in effect).
So, why there is an option visible? If you set the option visible, jCarousel sets the width of the visible items to always make this number of items visible. Open this example and resize your browser window to see it in effect.
Options for Carousel of Post Images
|skin||tango||Skin to use|
|imagesize||medium||Size of images to select. Does not affect the display just the images that are selected from the posts small,medium,large,full|
|orderby||rand||Display order, possible options see Wordress WP_Query Orderby parameters|
|postid||all||The ID of the post to select images from. If omitted will select from all posts|
|size||10||Number of images to select|
|div||post-carousel||ID of the list for the images. Only necessary to set when using more than one post carousel in a page/post|
|vertical||bool||false||Specifies wether the carousel appears in horizontal or vertical orientation. Changes the carousel from a left/right style to a up/down style carousel.|
|rtl||bool||false||Specifies wether the carousel appears in RTL (Right-To-Left) mode.|
|start||integer||1||The index of the item to start with.|
|offset||integer||1||The index of the first available item at initialisation.|
|scroll||integer||3||The number of items to scroll by.|
|visible||integer||null||If passed, the width/height of the items will be calculated and set depending on the width/height of the clipping, so that exactly that number of items will be visible.|
|animation||mixed||“fast”||The speed of the scroll animation as string in jQuery terms (“slow” or “fast”) or milliseconds as integer (See jQuery Documentation). If set to 0, animation is turned off.|
|easing||string||null||The name of the easing effect that you want to use (See jQuery Documentation).|
|auto||integer||0||Specifies how many seconds to periodically autoscroll the content. If set to 0 (default) then autoscrolling is turned off.|
|wrap||string||null||Specifies whether to wrap at the first/last item (or both) and jump back to the start/end. Options are “first”, “last”, “both” or “circular” as string. If set to null, wrapping is turned off (default).|
JQuery and all its contributors; a truly amazing project.
Originally started with the wp-simple-carousel but heavily modified, so much so that it’s a virtual rewrite but
even so Sergio Milardovich deserves a mention.
Support & Questions
Feel free to use the contact forms with any questions.
If you’d like to thank me for my time making this plugin by you can make a donation.