簡體   English   中英

Magento自定義價格未顯示在購物車/結帳中

[英]Magento custom price not displaying on cart/checkout

我正在測試以下ajax腳本。 我真的很擅長模塊開發,因此正嘗試以這種方式進行開發。 添加產品后,為什么動態價格不能正確反映在購物車頁面上? 我已經記錄了var_dump($ product-> debug()); 並且具有正確的變量自定義價格,原始自定義價格和isSuperMode(已建立數字和true)。

Ajax調用:

<?php
//error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
require_once('/var/www/Staging/public_html/app/Mage.php');
umask(0);
Mage::app(); 

//ensure that the value is legitimate
if($_POST && is_numeric($_POST['value'])){
   $price = $_POST['price'];
}

//pass this in your ajax call for the add button
if($_POST && is_numeric($_POST['product_id'])){
   $product_id = $_POST['product_id'];
}


$helper = Mage::helper('core'); //for translation

$block = new Mage_Catalog_Block_Product_View(); // not best practice, but neither are standalones
$product =  Mage::getModel('catalog/product')->load($product_id); // no need to use the _ here, it's not protected/private;


// Set the custom price
$product->setCustomPrice($price);
$product->setOriginalCustomPrice($price);
// Enable super mode on the product.
$product->getProduct()->setIsSuperMode(true); 

echo ('Custom Price is ' . $product->getCustomPrice() . ';   '); //has correct value
echo ('Custom Original Price is ' . $product->getOriginalCustomPrice() . ';   '); //has correct value

?>

這是具有ajax調用的函數。 發布變量正確。 它在可配置產品頁面上不可見地選擇供應商屬性的適用下拉選擇,最后一行將其添加到購物車。

    function selectAndAddToCart(value)
{
    var product_id= <?=$product_id ?>;
    var colorSelected = $j("#attribute92 option:selected").val();

    $j('#attribute136 option[value="' + value + '"]').prop('selected',true);

    $j('#attribute136').removeClass('validation-failed').addClass('validation-passed');

    var price = newPriceArray[value][colorSelected];
    console.log('The newPriceArray in selectAndAddToCart ' + price); //this is logging correctly

    //Save price in system
    $j.ajax({
        type: "POST",
        url: "/ajax_calls/savePrice.php",
        data: { 'product_id': product_id, 'price': price}
        }).done(function() {
                console.log('Prices have been updated in system');

                //initiate add to cart function
                productAddToCartForm.submit(this); 

    });//end inner ajax request

}

我認為保存是產品保存在這里不起作用

更換

Mage::app(); 

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

暫無
暫無

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

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