【问题标题】:Extract $item code from array in k2store从 k2store 的数组中提取 $item 代码
【发布时间】:2017-05-23 07:24:20
【问题描述】:

我尝试在 K2store 购物车页面(Joomla 的 K2 商店扩展)中提取并显示带有回显产品代码字段的页面,但没有成功。正确的值为“product_code”或“code”(是相同的值):26910。

“echo $item->product_name”和“echo $item->product_id”都有效,但“echo $item->code”和“echo $item->product_code”返回NULL。

var_dump($item) 给我看这个:

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)
}    

【问题讨论】:

  • 准备好了。解决方案是:$item->stock->product_code

标签: php joomla k2


【解决方案1】:

解决办法是:$item->stock->product_code

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多