CategoriesWordPress

Add SKU to WP e-Commerce Admin Reports

Верзија на српском је испод / Serbian version below

It is sometimes very important to add SKU display in admin report email (that is sent to admin when order is completed). Before WPEC (WP e-Commerce) version 3.8.9 it was possible like this. But not any more. There is some commercial solutions for this, but no „free“ solutions for so simple problem. Until now 🙂 Here it is (works for version 3.8.9.5):

1.) Open this file in your favorite text/code editor: /wp-content/plugins/wp-e-commerce/wpsc-includes/purchase-log-notification.class.php

2.) Somewhere around line 70  find this code:

$headings = array(
	_x( 'Name' , 'purchase log notification table heading', 'wpsc' ) => 'left',
	_x( 'Price' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'Quantity' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'Item Total' , 'purchase log notification table heading', 'wpsc' ) => 'right',
);

And replace it with this:

$headings = array(
	_x( 'Name' , 'purchase log notification table heading', 'wpsc' ) => 'left',
	_x( 'Price' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'Quantity' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'Item Total' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'SKU' , 'purchase log notification table heading', 'wpsc' ) => 'right',
);

3.) Somewhere around line 103  add this code:

$item_sku = wpsc_product_sku($item->prodid);

4.) Somewhere around line 105 find this code:

$rows[] = array( $item->name, $item_price, $item->quantity, $item_total );

And replace it with:

$rows[] = array( $item->name, $item_price, $item->quantity, $item_total, $item_sku );

5.) Leave a comment below 😉

Or, if you want quick solution, here is already changed file purchase-log-notification.class.php (you just need to replace old file with this one):

DOWNLOAD (zip) – For WP e-Commerce 3.8.12.1

Old version – 3.8.9.5: download

IMPORTANT: This file is from WP e-Commerce version 3.8.12.1, and may not work with older or newer versions of WPEC. I’ll try to keep file updated with new releases of WPEC.
IMPORTANT: Just in case something goes wrong, save backup of old purchase-log-notification.class.php file.
IMPORTANT: This process will modify WPEC core files, so if you update WPEC, all changes will be removed (you will have to do it again).

============================================================

Serbian version / Верзија на српском

============================================================

Додавање СКУ у извештаје о поруџбини у WP e-Commerce

Ако желите да се у емаил извештајима које WP e-Commerce шаље када неко заврши поруџбину на вашем сајту, појави и СКУ вашег производа, потребно је да:

1.) Отворите овај фајл у вашем едитору текста/кода: /wp-content/plugins/wp-e-commerce/wpsc-includes/purchase-log-notification.class.php

2.) Нeгде око линије 70, пронађите овај код:

$headings = array(
	_x( 'Name' , 'purchase log notification table heading', 'wpsc' ) => 'left',
	_x( 'Price' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'Quantity' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'Item Total' , 'purchase log notification table heading', 'wpsc' ) => 'right',
);

И замените га са овим кодом:

$headings = array(
	_x( 'Name' , 'purchase log notification table heading', 'wpsc' ) => 'left',
	_x( 'Price' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'Quantity' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'Item Total' , 'purchase log notification table heading', 'wpsc' ) => 'right',
	_x( 'SKU' , 'purchase log notification table heading', 'wpsc' ) => 'right',
);

3.) Негде око линије 103 додајте ово:

$item_sku = wpsc_product_sku($item->prodid);

4.) Негде око линије 105, пронађите овај код:

$rows[] = array( $item->name, $item_price, $item->quantity, $item_total );

И замените га са овим кодом:

$rows[] = array( $item->name, $item_price, $item->quantity, $item_total, $item_sku );

5.) Оставите коментар испод 😉

Или ако желите неко брже решење, ево измењеног фајла purchase-log-notification.class.php (само треба да замените стари фај са овим):

ПРЕУЗМИ (zip) – За WP e-Commerce 3.8.12.1

Стара верзија – 3.8.9.5: преузми

ВАЖНО: Овај фајл је из WP e-Commerce верзије 3.8.12.1, и можда не ради са старијим или новијим верзијама WP e-Commerce. Потрудићу се да овај фајл буде увек ажуран са најновијом верзијом WP e-Commerce.
ВАЖНО: За сваки случај сачувајте резервну копију вашег старог purchase-log-notification.class.php фајла.
ВАЖНО: Овај процес ће модификовати „основне“ WP e-Commerce фајлове, тако да ће све промене бити изгубљене ако ажурирате WP e-Commerce додатак и мораћете поново да учините измене ако желите да се СКУ појави.

8 коментара на “Add SKU to WP e-Commerce Admin Reports”

Just wanted to say thank you very much for this code. It was exactly what I needed and it worked perfectly. I do not understand why WP e-Commerce does not include the SKU on the emails. I would think that would be a default item. The ability to easily customize those emails should be something simple to do and easy to find and it is neither. Thank goodness I happened upon your article. Thanks again.

I’m glad I could help you Elizabeth. WP e-Commerce is great piece of software, but unfortunately, for a long time authors fails to implement some basic functionalities (for example: there is no backend option for removing decimal places from product price, so users must edit core files every time). I hope they will implement some of the missing features in future updates.

Thank you for the code. Easy, clear instructions. I also need to add product image to the admin report. I tried to follow the same process with $item_img but was not successful. Appreciate your thoughts.

Thanks for your reply. Unfortunately, it did not work.
If I paste the code that is received (in place of the image) in the admin report, into the browser address bar it returns the error:Invalid Image parameters.
An alternative would be to include in the admin report a permalink to the actual product, in place of the image.
Many thanks for your help.

Hi,

I made little mistake there, but it seems there is another bigger problem – WPEC won’t display html in emails (it displays html as plaintext), so html can’t work there. I don’t know how to override this. However, links can be displayed in plaintext format (but then you need to do copy/paste to go that address), like this:
Item url: get_permalink($item->prodid)
Item image: $thumbzt = wp_get_attachment_image_src( get_post_thumbnail_id($item->prodid), 'thumbnail');
$item_thumb = $thumbzt[0];

Оставите одговор

Ваша адреса е-поште неће бити објављена. Неопходна поља су означена *