久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在選擇時將添加到購物車按鈕更改為預購

Change Add to cart button to Preorder on select(在選擇時將添加到購物車按鈕更改為預購)
本文介紹了在選擇時將添加到購物車按鈕更改為預購的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如果在可配置的選定產品上選擇了一個選項,我在使用 php 和 jquery for magento 將按鈕從添加到購物車更改為預訂時遇到了一個小麻煩.

i have a small trouble to get working a php and jquery for magento to change button from add to cart to preorder if an option is selected on configurable selected product.

用于檢查可配置中的簡單子產品之一是否已選擇該選項的 php.

The php to check if one of the simple children products from configurable has the option selected.

<?php
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();

$productMap = array();
foreach($col as $simpleProduct){
    $productMap[$simpleProduct->getId()] = $simpleProduct->getAttributeText('preorder');
    //$test = $simpleProduct->getId() && $simpleProduct->getAttributeText('preorder');
}
?>

回聲結果:預購

如果所選產品有選項,Jquery 更改按鈕.

Jquery to change the button if the selected product has the option.

<?php if($productMap) { ?>
<script type="text/javascript">
    jQuery(document).ready(function() {

        // On document ready hide the button to preorder first
        jQuery("#addtopreorder").hide();
        jQuery("#addtocart").show();
        jQuery("#<?=$productMap ?>").change(function() { 
            // Hide the button to preorder on slect element change action
            jQuery("#addtopreorder").hide();

            // Get the value of selected option
            var optionValue = jQuery(this).attr('value');
            // Just a test to see if you're getting option value
            //alert(optionValue);
            // Get the content (aka inner HTML) of selected option
            var optionValueText = jQuery.trim(jQuery('#<?=$productMap ?> :selected').text());

            // Just a test to see if you're getting right selected option inner text
            // alert(optionValueText);
            // alert('Selected option has value: ' + optionValue + ' and inner text: ' + optionValueText);

            // Show the button based on selected value
            // Whatch out, case sensitive...
            if( ! optionValue ){ 
                jQuery("#addtocart").show();
            } else {
                jQuery("#addtopreorder").show();
            }
        });
    });
</script>

感謝任何幫助.

推薦答案

問題由 SCP Simple Configurable Product 解決.由有機互聯網制作.

Issue resolved by SCP Simple Configurable Product. made by Organic Internet.

擴展鏈接

這篇關于在選擇時將添加到購物車按鈕更改為預購的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 国产精品一区二区不卡 | 精久久 | www.日日干| 欧美性区| 欧美一级做a爰片免费视频 国产美女特级嫩嫩嫩bbb片 | 久久久久久国产精品免费免费 | 成人亚洲精品久久久久软件 | 亚洲一区 | 日韩三级在线观看 | 欧美精品成人 | 免费视频成人国产精品网站 | 国产乱码精品一区二区三区中文 | 中文字幕 国产 | 神马影院一区二区三区 | 日韩视频二区 | 激情网站在线观看 | 天天干免费视频 | 农夫在线精品视频免费观看 | 黑人性hd | 成在线人视频免费视频 | 国产一区二区三区免费 | 91精品国产一区二区三区 | 国产综合久久久久久鬼色 | 日韩免费视频一区二区 | 欧美午夜精品 | 日韩视频高清 | 麻豆a级片 | www.国产精品 | 久久国产精品免费一区二区三区 | 欧美在线观看一区二区 | 日韩国产三区 | 一区二区三区国产精品 | 中文字幕中文字幕 | 日韩激情在线 | 国产精品视频网站 | 欧美一级网站 | 日韩成人在线观看 | 国产精品免费一区二区三区四区 | 国产三级一区二区三区 | 久久久久久国产精品 | 欧美激情精品久久久久久 |