2017-05-23 58 views
1

我嘗試提取並在頁面上顯示K2store購物車頁面中的echo產品代碼字段(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) 
}  
+0

就緒。解決方案是:$ item-> stock-> product_code –

回答

0

解決的辦法是:$item->stock->product_code