簡體   English   中英

Prestashop 1.6數量檢查

[英]Prestashop 1.6 quantity check

請幫助我解決一個問題。 在我的Prestashop 1.6.0.14上,我正在嘗試檢查product.tpl中的數量,在該部分下:

<p id="add_to_cart" {if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || (isset($restricted_country_mode) && $restricted_country_mode) || $PS_CATALOG_MODE}style="display:none"{/if} class="buttons_bottom_block">
<button type="submit" name="Submit" class="exclusive lmromancaps">{l s='Add to cart'}</button>
</p>   

我正在嘗試添加代碼:

{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || (isset($restricted_country_mode) && $restricted_country_mode) || $PS_CATALOG_MODE }
<input type="button" class="exclusive lmromancaps b1c" value="Order">
{else}
<input type="button" class="exclusive lmromancaps b1c" value="Quick buy">
{/if} 

但是,當產品沒有數量時,這種情況永遠不會發生。 此代碼僅適用於沒有任何屬性和特征的產品,但是對於具有特征和屬性的產品,我無法檢查數量。

例如,如果產品具有顏色1,數量= 1,顏色2,數量= 0的屬性,則我的代碼看不到顏色2沒有數量,而是看到它具有數量。 請幫我做,我做錯了什么? 謝謝。

product.tpl您可以訪問$combinations (產品屬性),其中包含所有組合數據,包括數量:

{foreach from=$combinations item=combination}
    {$combination->quantity} 
{/foreach}

從另一面看,默認情況下,大多數prestashop主題都使用“頁面交互式屬性選擇”(可能是不正確的單詞,我的英語不好,很抱歉),我的意思是當您單擊“顏色”時,您可以看到“庫存”而無需服務器等。在模板中,您可能會看到類似以下內容:

{addJsDef combinations=$combinations}
{addJsDef combinationsFromController=$combinations}

並且您可以在您的javascript代碼中訪問例如combinationsFromController變量:

for(i in combinationsFromController) { 
   console.log(combinationsFromController[i].quantity);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM