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。
- 2 回答
- 0 關(guān)注
- 166 瀏覽
添加回答
舉報
0/150
提交
取消