Extract $item code from array in k2store

59 Views Asked by At

I try to extract and to show on the page with echo product code field in K2store cart page (store extension for K2 for Joomla) but without success. The right value is "product_code" or "code" (is the same value): 26910.

Both "echo $item->product_name" and "echo $item->product_id" works, but "echo $item->code" and "echo $item->product_code" return NULL.

var_dump($item) show me this:

object(stdClass)#381 (13) {
  ["key"]=>
  int(9928417)
  ["product_id"]=>
  string(7) "9928417"
  ["product_name"]=>
  string(71) "some title"
  ["product_model"]=>
  NULL
  ["product_total"]=>
  int(1)
  ["product_options"]=>
  object(stdClass)#382 (0) {
  }
  ["quantity"]=>
  int(1)
  ["stock"]=>
  object(JObject)#378 (18) {
    ["_errors":protected]=>
    array(0) {
    }
    ["item_enabled"]=>
    string(1) "1"
    ["item_sku"]=>
    NULL
    ["item_price"]=>
    NULL
    ["special_price"]=>
    NULL
    ["item_tax_id"]=>
    NULL
    ["item_shipping"]=>
    NULL
    ["item_qty"]=>
    NULL
    ["item_cart_text"]=>
    NULL
    ["product_id"]=>
    string(7) "9928417"
    ["product_name"]=>
    string(71) "some title"
    ["product_code"]=>
    string(5) "26910"
    ["price"]=>
    NULL
    ["product_sku"]=>
    NULL
    ["tax_profile_id"]=>
    NULL
    ["item_minimum"]=>
    string(1) "1"
    ["stock"]=>
    *RECURSION*
    ["product"]=>
    object(stdClass)#354 (38) {
      ["id"]=>
      string(7) "9928417"
      ["code"]=>
      string(5) "26910"
      ["title"]=>
      string(71) "some title"
      ["alias"]=>
      string(71) "some title"
      ["catid"]=>
      string(3) "694"
      ["published"]=>
      string(1) "1"
      ["introtext"]=>
      string(0) ""
      ["fulltext"]=>
      string(0) ""
      ["video"]=>
      NULL
      ["gallery"]=>
      NULL
      ["extra_fields"]=>
      string(29) "[{"id":"1","value":"25\/40"}]"
      ["extra_fields_search"]=>
      string(6) "25/40 "
      ["created"]=>
      string(19) "2012-09-14 10:20:09"
      ["created_by"]=>
      string(2) "52"
      ["created_by_alias"]=>
      string(0) ""
      ["checked_out"]=>
      string(1) "0"
      ["checked_out_time"]=>
      string(19) "0000-00-00 00:00:00"
      ["modified"]=>
      string(19) "2012-09-14 10:30:46"
      ["modified_by"]=>
      string(2) "52"
      ["publish_up"]=>
      string(19) "2012-09-14 10:20:09"
      ["publish_down"]=>
      string(19) "0000-00-00 00:00:00"
      ["trash"]=>
      string(1) "0"
      ["access"]=>
      string(1) "1"
      ["ordering"]=>
      string(1) "1"
      ["featured"]=>
      string(1) "0"
      ["featured_ordering"]=>
      string(1) "0"
      ["image_caption"]=>
      string(0) ""
      ["image_credits"]=>
      string(0) ""
      ["video_caption"]=>
      string(0) ""
      ["video_credits"]=>
      string(0) ""
      ["hits"]=>
      string(5) "17852"
      ["params"]=>
      string(1190) "catItemTitle=
catItemTitleLinked=
catItemFeaturedNotice=
catItemAuthor=
catItemDateCreated=
catItemRating=
catItemImage=
catItemIntroText=
catItemExtraFields=
catItemHits=
catItemCategory=
catItemTags=
catItemAttachments=
catItemAttachmentsCounter=
catItemVideo=
catItemVideoWidth=
catItemVideoHeight=
catItemVideoAutoPlay=
catItemImageGallery=
catItemDateModified=
catItemReadMore=
catItemCommentsAnchor=
catItemK2Plugins=
itemDateCreated=
itemTitle=
itemFeaturedNotice=
itemAuthor=
itemFontResizer=
itemPrintButton=
itemEmailButton=
itemSocialButton=
itemVideoAnchor=
itemImageGalleryAnchor=
itemCommentsAnchor=
itemRating=
itemImage=
itemImgSize=
itemImageMainCaption=
itemImageMainCredits=
itemIntroText=
itemFullText=
itemExtraFields=
itemDateModified=
itemHits=
itemTwitterLink=
itemCategory=
itemTags=
itemShareLinks=
itemAttachments=
itemAttachmentsCounter=
itemRelated=
itemRelatedLimit=
itemVideo=
itemVideoWidth=
itemVideoHeight=
itemVideoAutoPlay=
itemVideoCaption=
itemVideoCredits=
itemImageGallery=
itemNavigation=
itemComments=
itemAuthorBlock=
itemAuthorImage=
itemAuthorDescription=
itemAuthorURL=
itemAuthorEmail=
itemAuthorLatest=
itemAuthorLatestLimit=
itemK2Plugins=

"
      ["metadesc"]=>
      string(0) ""
      ["metadata"]=>
      string(15) "robots=
author="
      ["metakey"]=>
      string(0) ""
      ["plugins"]=>
      string(27) "{"k2storeitem_enabled":"1"}"
      ["code_search"]=>
      string(0) ""
      ["language"]=>
      string(0) ""
    }
  }
  ["tax_amount"]=>
  int(0)
  ["price"]=>
  int(0)
  ["price_without_tax"]=>
  int(0)
  ["total"]=>
  int(0)
  ["total_without_tax"]=>
  int(0)
}    
1

There are 1 best solutions below

0
On

The solution is: $item->stock->product_code