duanmanpi9358 2017-05-23 07:24
浏览 129

从k2store中的数组中提取$ item代码

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条回答 默认 最新

  • duanbi6522 2017-06-07 12:17
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法