Category Archives: WP Ecommerce

Get Category Slug on Single Product Page

In wpsc_single-product.php:

 PHP |  copy code |? 
1
//get cat of product
2
$query_data = Array();
3
$pr_post_id = wpsc_the_product_id();
4
$categories = wp_get_object_terms($pr_post_id , 'wpsc_product_category' );
5
//if product is associated with more than one category
6
if(count($categories) > 1 && isset($wpsc_query->query_vars['wpsc_product_category']))
7
$query_data['category'] = $wpsc_query->query_vars['wpsc_product_category'];
8
elseif(count($categories) > 0)
9
$query_data['category'] = $categories[0]->slug;

Then you can use the category slug as follows for example:

 PHP |  copy code |? 
1
 if($query_data['category'] == "t-shirts"){ //show size charts; ?>
2
//show size charts
3
<?php } ?>

This is based on a useful function posted here:

http://isabelcastillo.com/highlight-current-category-in-menu-on-single-product-page-wpec

Posted in Plugins, Wordpress 3, WP Ecommerce | Leave a comment

WP Ecommerce variation out of stock message

When a variation is out of stock WP Ecommerce defaults to saying that the product is out of stock rather than just the variation.

There is fork on Git hub covering this at:

https://github.com/wp-e-commerce/WP-e-Commerce/pull/495

The fix is as follows:

wp-content/plugins/wp-e-commerce/wpsc-includes/ajax.functions.php

Around line 100 change as follows:

 PHP |  copy code |? 
1
-      $cart_messages[] = sprintf( __( 'Sorry, but the item "%s" is out of stock.', 'wpsc' ), $product->post_title  );
2
+      $cart_messages[] = sprintf( __( 'Sorry, but the item "%s" is out of stock.', 'wpsc' ), get_the_title( $product_id )  ); 

Posted in Plugins, Wordpress 3, WP Ecommerce | Leave a comment

WP Ecommerce Shop Styling Purchase Table in Email Template

Using the WP Ecommerce Shop Styling plugin.

Email template product table is improved by adding the following styling to the email template:

 CSS |  copy code |? 
1
#products-table { width: 100%;}
2
#products-table td {padding:5px;}
3
#products-table th{text-align: left;}

Posted in CSS, WP Ecommerce | Leave a comment

Update Text Using PO Files. Translate Text.

A basic guide to translating wp-e-commerce using poEdit

1. Download and Install poEdit : http://www.poedit.net/download.php
2. Run poEdit and open a translation file (.po) from the `wp-e-commerce/languages` folder
3. Go through the list of words / sentences and add in your translations
4. In poEdit make sure you have the box checked in Preferences>Editor ‘Automatically Save .mo file on save’
5. Save your translation file in the `wp-e-commerce/languages` folder give it a descriptive name ie: wpsc-en_US means english – american, wpsc-fr_FR means french – france (note: your filename must have ‘wpsc-’ at the start to work)
6. In your wordpress wp-config.php file edit the line that looks like this:
`define (‘WPLANG’, ”);`
with the file name (without extension) inside the second set of quotation marks.
i.e If I saved my mo file as `wpsc-en_BG.mo` then I would change the WPLANG line to:
`define (‘WPLANG’, ‘en_BG’);`
7. Save your wp-config.php
8. Refresh your website in a web browser, your new translations should now be viewable on your site.

References
http://codex.wordpress.org/WordPress_in_Your_Language
http://codex.wordpress.org/I18n_for_WordPress_Developers
http://www.forumone.com/blogs/post/translating-your-wordpress-site-using-pot-file

Posted in Tips and Tricks, Wordpress 3, WP Ecommerce | Leave a comment

Wp Ecommerce Responsive CSS

Add the following CSS rules to make WP-Ecommerce plugin more responsive to mobile devices:

 CSS |  copy code |? 
01
#content .product_grid_display .item_image a {
02
   display: inline;
03
}
04
#primary #content #grid_view_products_page_container, #primary #content #grid_view_products_page_container, #primary #content #list_view_products_page_container {
05
  line-height: 1.2em;
06
  min-width: 300px;
07
  position: relative;
08
  width: 100%;
09
}
10
#default_products_page_container .imagecol img, #list_view_products_page_container img, #grid_view_products_page_container img {
11
   height: auto !important;
12
 }
13
#checkout_page_container {
14
  clear: both;
15
  position: relative;
16
  width: 100%;
17
}

Posted in WP Ecommerce | Leave a comment

Hide Shipping Calculator for Flat Rate Shipping

The aim is to only hide the calculator from the checkout page not remove it as it still must send its values to the next page. It is then removed from the layout by setting its position as absolute so it does not push the forms down the page.

Also need to remove the H2 heading.

In the theme stylesheet add the following:

 CSS |  copy code |? 
1
#content #checkout_page_container table.productcart {
2
visibility: hidden;
3
position: absolute;
4
}
5
 
6
#wpsc_shopping_cart_container h2:first-child {
7
display: none;
8
}

Posted in WP Ecommerce | Leave a comment

WP E-Commerce Sales Log Date Wrong Time Zone

Set the server timezone by adding this to top of your  functions.php file of your theme:

 PHP |  copy code |? 
1
<?php
2
    // set default timezone for wp -ecommerce to NZ time
3
    date_default_timezone_set ('Pacific/Auckland' );  
4
?>

Time zones are detailed here:

http://www.php.net/manual/en/timezones.php

Posted in Code, Plugins, WP Ecommerce | 1 Comment

WP-Eccommerce Get Purchase Log Data

To retrieve the purchase log data to extract customer email for example use this within the function:

 PHP |  copy code |? 
01
global $wpdb;
02
 
03
    //This grabs the purchase log id from the database that refers to the $sessionid
04
 
05
    $purchase_log = $wpdb->get_row(
06
    "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= ".$sessionid." LIMIT 1" ,ARRAY_A) ;
07
//This grabs the users info using the $purchase_log from the previous SQL query
08
&nbsp;   $usersql = "SELECT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value,
09
    `".WPSC_TABLE_CHECKOUT_FORMS."`.`name`,
10
    `".WPSC_TABLE_CHECKOUT_FORMS."`.`unique_name` FROM
11
    `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN
12
    `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON
13
    `".WPSC_TABLE_CHECKOUT_FORMS."`.id =
14
    `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE
15
    `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`log_id`=".$purchase_log['id']."";
16
 
17
 
18
    $userinfo = $wpdb->get_results($usersql, ARRAY_A);
19
 
20
 
21
    //get for example, customer email address
22
    foreach((array)$userinfo as $key => $value){
23
 
24
         if(($value['unique_name']=='billingemail') && $value['value'] != ''){
25
                $customer_email = $value['value'];
26
                }
27
     }

Keys correspond to the checkout fields unique names

Posted in WP Ecommerce | Leave a comment

WP-Ecommerce $item array keys

 PHP |  copy code |? 
01
[purchase_id]
02
[cart_item]
03
--[id]
04
--[prodid]
05
--[name]
06
--[purchaseid]
07
--[price]
08
--[pnp]
09
--[tax_charged]
10
--[gst]
11
--[quantity]
12
--[donation]
13
--[no_shipping]
14
--[custom_message]
15
--[files]
16
--[meta]
17
[purchase_log]
18
--[id]
19
--[totalprice]
20
--[statusno]
21
--[sessionid]
22
--[transactid]
23
--[authcode]
24
--[processed]
25
--[user_ID]
26
--[date]
27
--[gateway]
28
--[billing_country]
29
--[shipping_country]
30
--[base_shipping]
31
--[email_sent]
32
--[stock_adjusted]
33
--[discount_value]
34
--[discount_data]
35
--[track_id]
36
--[billing_region]
37
--[shipping_region]
38
--[find_us]
39
--[engravetext]
40
--[shipping_method]
41
--[shipping_option]
42
--[affiliate_id]
43
--[plugin_version]
44
--[notes]
45
--[wpec_taxes_total]
46
--[wpec_taxes_rate] 

Posted in WP Ecommerce | Leave a comment

Thickbox not working on Product Images – conflict with Better WP Security settings

Symptom:
Clicking on a product image launches screen overlay but image doesn’t appear.

Conditions:
Using WP Ecommerce plugin and Better WP Sucurity Plugin

Cause:
Better WP Security settings under Server Tweaks, this item
“Display random version number to all non-administrative users”
Kills Thickbox

Posted in Better WP Security, Tips and Tricks, Wordpress 3, WP Ecommerce | Leave a comment