20 replies [Last post]
samdds's picture
Offline
Joined: 08/17/2010
Juice: 72
Was this information Helpful?

Hello,
I want to add the SKU to the cart page. How can I do this?
I've tried some options which are described on the forums, but when creating a new module I get the error
'The module is not compatible with 6.16 core'

Any clue?

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: How to add SKU to cart page?

When I've had that error I've found there's been a typo in the .info file. Try creating the file again or using the one from the uber module template file (skeleton.tar) from here:

http://www.ubercart.org/docs/developer/238/coding_standards

Also if you haven't seen this post already it may be of some help

http://www.ubercart.org/forum/support/2458/add_sku_cart

samdds's picture
Offline
Joined: 08/17/2010
Juice: 72
Re: Re: How to add SKU to cart page?

Yes, I've seen that post, so what I'm trying to do here, is this:
http://www.ubercart.org/comment/55731

I dont't really see any typo there..

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: Re: How to add SKU to cart page?

can you post your modules .info file here?

samdds's picture
Offline
Joined: 08/17/2010
Juice: 72
Re: Re: Re: Re: How to add SKU to cart page?

I just copy it from the link I posted

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: Re: Re: Re: How to add SKU to cart page?

Yes, but could you copy it to a post here too.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: Re: Re: Re: Re: How to add SKU to cart page?

Don't worry I found it. As an aside I'm finding this site really slow at the moment, not sure if it's my ISP or not.

Anyway cut and paste this .info to get rid of that error message.

; $Id$
name = Show SKU
description = Add SKU column to Product and Cart tables
dependencies[] = uc_cart
package = "Ubercart - core (optional)"
core = 6.x
samdds's picture
Offline
Joined: 08/17/2010
Juice: 72
Re: Re: Re: Re: Re: Re: Re: How to add SKU to cart page?

Still doesn't work, when I copy your code, it still gives the same error...
Haven't got much hair left to be honest..

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Hiya, Just to double

Hiya,

Just to double check:

You are using drupal 6 and ubercart 2.x ?

I've attached a version which works here. If it doesn't work for you maybe re-install ubercart?

AttachmentSize
uc_show_sku.zip 2.14 KB
samdds's picture
Offline
Joined: 08/17/2010
Juice: 72
Re: Hiya, Just to double

I am using Ubercart 6.x-2.2, so I guess that's right?
Can you re-upload the attachment please? It says: The page you requested does not exist.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: Hiya, Just to double

Here's the code and attachment again.

uc_show_sku.info

; $Id$
name = Show SKU
description = Add SKU column to Product and Cart tables
dependencies[] = uc_cart
core = 6.x

uc_show_sku.module

<?php
// $Id$
/**
* show the sku
*/
function uc_show_sku_form_alter(&$form, $form_state, $form_id) {

if ($form_id == 'uc_cart_view_form') {
//Here I just remove the image column
$form['items']['#columns']['image']['access'] = FALSE;

//Add the Titles in the table header row
$form['items']['#columns']['model']['cell'] = 'SKU';
$form['items']['#columns']['desc']['cell'] = 'Description';

//Now I am moving around the columns by adjusting the weight
$form['items']['#columns']['remove']['weight'] = 0;
$form['items']['#columns']['model']['weight'] = 1;
$form['items']['#columns']['desc']['weight'] = 2;
$form['items']['#columns']['qty']['weight'] = 3;
$form['items']['#columns']['total']['weight'] = 4;

//There are 6 fields in this array other than the cart items, so I loop through and don't account for those 6... haha elegant!
for($i=0;$i<count(uc_cart_get_contents());$i++){
//So... I don't know if there's another way to get the info from the node other than using node_load but since it comes from cache it's fast right?

$form['items'][$i]['model']['#value'] = node_load($form['items'][$i]['nid']['#value'])->model; // Load the SKU from the product node
}
}
}

I think I forgot to click 'attach' the last time I posted the file.

AttachmentSize
uc_show_sku.zip 2.14 KB
samdds's picture
Offline
Joined: 08/17/2010
Juice: 72
Re: Re: Re: Hiya, Just to double

Thank you, I managed to enable the module.

Last question: do I have to enable a checkbox somewhere? Or should the SKU be visible after enabling the module? (because it isnt)

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: Re: Re: Hiya, Just to double

You should see the SKU in the cart.

I didn't enable anything extra, once I'd ironed out the errors the SKU appeared in the cart.

samdds's picture
Offline
Joined: 08/17/2010
Juice: 72
Re: Re: Re: Re: Re: Hiya, Just to double

sorry, it was a newby mistake (like the others)
It's working now. You've saved my day mate, thanks alot. Now I just got to figure out how to show the SKU on the checkout page

amanda1919's picture
Offline
Joined: 10/11/2011
Juice: 32
oncreative wrote: Here's the
oncreative wrote:

Here's the code and attachment again.

uc_show_sku.info

; $Id$
name = Show SKU
description = Add SKU column to Product and Cart tables
dependencies[] = uc_cart
core = 6.x

uc_show_sku.module

<?php
// $Id$
/**
* show the sku
*/
function uc_show_sku_form_alter(&$form, $form_state, $form_id) {

if ($form_id == 'uc_cart_view_form') {
//Here I just remove the image column
$form['items']['#columns']['image']['access'] = FALSE;

//Add the Titles in the table header row
$form['items']['#columns']['model']['cell'] = 'SKU';
$form['items']['#columns']['desc']['cell'] = 'Description';

//Now I am moving around the columns by adjusting the weight
$form['items']['#columns']['remove']['weight'] = 0;
$form['items']['#columns']['model']['weight'] = 1;
$form['items']['#columns']['desc']['weight'] = 2;
$form['items']['#columns']['qty']['weight'] = 3;
$form['items']['#columns']['total']['weight'] = 4;

//There are 6 fields in this array other than the cart items, so I loop through and don't account for those 6... haha elegant!
for($i=0;$i<count(uc_cart_get_contents());$i++){
//So... I don't know if there's another way to get the info from the node other than using node_load but since it comes from cache it's fast right?

$form['items'][$i]['model']['#value'] = node_load($form['items'][$i]['nid']['#value'])->model; // Load the SKU from the product node
}
}
}

I think I forgot to click 'attach' the last time I posted the file.

I want to download file, but it is not there anymore, can you reupload please

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: oncreative wrote: Here's the

It took me a while to find it but here it is again.

AttachmentSize
uc_show_sku.zip 2.14 KB
bobknocker's picture
Offline
Joined: 11/17/2010
Juice: 37
Products with adjustments

Hi, i have followed everything on the post and the SKU is showing in the cart as expected, however many of my products have adjustments so i need to show the alternate SKU as the SKU currently showing is for the base product.

any chance you could point me in the right direction please

amanda1919's picture
Offline
Joined: 10/11/2011
Juice: 32
thank you it works

thank you

it works

amanda1919's picture
Offline
Joined: 10/11/2011
Juice: 32
Re: thank you it works

but now the images dissapered from the cart, is there a fix to get them back?

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: thank you it works

If you look at post #10 it shows how to remove the images which are normally displayed:

$form['items']['#columns']['image']['access'] = FALSE;

Just change this line from FALSE to TRUE or maybe removing this line entirely should bring the images back (but I've not tested that option).

garin33's picture
Offline
Joined: 07/21/2011
Juice: 10
Hi Users! Can i add taxonomy

Hi Users!
Can i add taxonomy terms in cart page? How change code for this?

Greetings from Russia, my English - translate.google.ru Smiling.
Drupal forever.