第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PrestaShop 1.7 如何在產(chǎn)品頁面上獲取 id_product_attribute?

PrestaShop 1.7 如何在產(chǎn)品頁面上獲取 id_product_attribute?

PHP
湖上湖 2021-06-11 10:05:29
id_product_attribute 在 URL 中可用 - 值“10”: http://localhost/presta/women/2-10-brown-(...).html#/2-size-m我需要從當前產(chǎn)品頁面獲取當前 id_product_attribute??赡軄碜?$_GET,或來自 DOM 元素,或 presta shop 變量 - 但我必須在添加到購物車之前將其傳遞給 JavaScript 函數(shù)(即使最終客戶沒有將產(chǎn)品添加到購物車 - 這就是為什么我可以不使用鉤子:“actionCartSave”)我可以從鉤子 displayAfterProductThumbs 訪問這個值 - 但是獲取當前值有問題。為了獲得正確的價值,我需要:1)在產(chǎn)品頁面選擇產(chǎn)品屬性(尺寸、顏色)2)刷新頁面觸發(fā)鉤子“displayAfterProductThumbs”3)讀取數(shù)據(jù)但我需要它而不刷新。在文檔中,我什么也找不到。試圖尋找短語:id_product_attribute、id_combination、idCombination、ipa。關(guān)于 id_product_attribute(在 Google 上找到)的大多數(shù)信息都與 SEO 相關(guān),并且“出于 SEO 目的,在 url 中包含 id_product_attribute 并不是一個好主意”。
查看完整描述

2 回答

?
慕姐8265434

TA貢獻1813條經(jīng)驗 獲得超2個贊

有一個名為 displayProductAdditionalInfo 的鉤子。在模塊中注冊鉤子,并在參數(shù)中獲取產(chǎn)品詳細信息。當我們更改產(chǎn)品的組合時,此代碼將運行。因此 idProductAttribute 將在組合更改時自動更新。


public function hookDisplayProductAdditionalInfo($params)

{

    if isset($params['product']) {

        //  Now return the input type hidden with idproductattribute 

       return '<input type="hidden" name="id_product_attribute" id="product_attribute_info" value="'.$params['product']['id_product_attribute'].'"/>';

    }

}

現(xiàn)在點擊添加到購物車阻止默認操作并從輸入隱藏字段中獲取 idProductAttribute。


查看完整回答
反對 回復 2021-06-13
  • 2 回答
  • 0 關(guān)注
  • 166 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號