Support » Plugin: WP eCommerce » SKU in wpsc-shopping_cart_page.php (checkout page)?

  • Resolved chavo

    (@chavo)


    Hi, I’m developing a store in my local machine (localhost) and I’m trying to show SKU in checkout page.

    I’m using
    WordPress version: 3.7.1
    WP e-Commerce version: 3.8.12

    I tried with the next piece of code that I found at this link

    <?php
    echo wpsc_product_sku(wpsc_cart_item_product_id());
    ?>

    Anyway, the code it isn’t working. But if I use the next piece of code sku is printed.

    <?php echo $sku = get_post_meta(130, '_wpsc_sku' , true); ?>

    130 is the post id of the product (handcoded). So, I tried something like this:

    <?php
    $id = wpsc_cart_item_product_id();
    echo $sku = get_post_meta($id, '_wpsc_sku' , true); ?>

    But…I noticed that in checkout page, the product id isn’t the same as post id for each item. In wpsc-single_product.php the product id and post id are the same value.

    Does anyone known how to print SKU value in checkout page?

    Thanks in advance and sorry for my english.

    http://wordpress.org/plugins/wp-e-commerce/

Viewing 1 replies (of 1 total)
  • Well, I don’t know if is the best solution, but a I get it!!!
    I took a look at the database and I noticed that the “post_parent” value is what I have to obtain because each item has a different product ID based on variations but “post_parent” remains the same.

    So, reading a little at this link I tried:

    <?php
    $product_id = wpsc_cart_item_product_id(); //find product id
    $parent = $wpdb->get_var( $wpdb->prepare("SELECT post_parent FROM $wpdb->posts WHERE ID = %d", $product_id ) ); // find post_parent based on product_id
    echo $sku = get_post_meta($parent, '_wpsc_sku' , true); // print sku based on post_parent ID
    ?>

    It works!

Viewing 1 replies (of 1 total)
  • The topic ‘SKU in wpsc-shopping_cart_page.php (checkout page)?’ is closed to new replies.