2014-10-02 2 views
0

나는 무슨 일이 벌어지고 있는지 꽤 생각해. 나는 그것을 고치는 방법에 대한 단서가 없다. 페이팔에 광고 항목을 포함하도록 요청 했으므로 총 광고 항목은 계산되지만 총합과 일치하지는 않습니다.PayPal 게이트웨이가 요청을 거부했습니다. 장바구니 품목 금액의 합계가 주문 금액과 일치하지 않습니다. Magento

내가 자습서 나에게 모든 것을 한 적이

<?php 
/** 
* Created by PhpStorm. 
* User: numerical25 
* Date: 5/17/14 
* Time: 7:49 PM 
*/ 

class Superior_WinInts_Model_Globaldiscount extends Mage_Sales_Model_Quote_Address_Total_Subtotal { 

    protected $amount = 0; 
    protected $set = 0; 

    public function collect(Mage_Sales_Model_Quote_Address $address) { 
     if ($address->getData('address_type') == 'billing') 
      return $this; 
     $discount = Mage::app()->getRequest()->getParam('global_discount_amount'); 
     $grandTotal = $address->getGrandTotal(); 
     $baseGrandTotal = $address->getBaseGrandTotal(); 
     if(Mage::getSingleton('customer/session')->isLoggedIn() && $discount) { 

      $customer = Mage::getModel('customer/customer')->load(Mage::getSingleton('customer/session')->getId()); 
      $credit = Mage::getModel("winints/wallet") 
       ->getCustomerStoreCreditTotal($customer->getId()); 
      if($credit >= $discount) { 
       $this->amount = $discount; 
      } 
      Mage::getSingleton('core/session')->setGlobalDiscount($discount); 

      $totals = array_sum($address->getAllTotalAmounts()); 
      $baseTotals = array_sum($address->getAllBaseTotalAmounts()); 
      //You have to set Grand and Base Grand Total for this crap to work 
      $address->setDiscountAmount(-$discount); 
      $address->setBaseDiscountAmount(-$discount); 
      $address->setGrandTotal($grandTotal - $discount); 
      $address->setBaseGrandTotal($baseGrandTotal - $discount); 
      $address->setSubtotal($baseGrandTotal - $discount); 

     } else if (Mage::getSingleton('core/session')->getGlobalDiscount()) { 
      $discount = Mage::getSingleton('core/session')->getGlobalDiscount(); 
      $this->amount = Mage::getSingleton('core/session')->getGlobalDiscount(); 
      $address->setDiscountAmount(-$discount); 
      $address->setBaseDiscountAmount(-$discount); 
      $address->setGrandTotal($grandTotal - $discount); 
      $address->setBaseGrandTotal($baseGrandTotal - $discount); 
      $address->setSubtotal($baseGrandTotal - $discount); 
     } 
     return $this; 
    } 

    public function fetch(Mage_Sales_Model_Quote_Address $address) 
    { 
     if(Mage::getSingleton('core/session')->getGlobalDiscount()) { 
      if(!$this->set) { 
       $address->addTotal(array(
        'code'=>$this->getCode(), 
        'title'=>Mage::helper('catalog')->__('Global Discount (-)'), 
        'value'=> $this->amount 
       )); 
       $this->set = 1; 
      } 
     } 
     return $this; 
    } 
} 

config.xml에

<sales> 
     <quote> 
      <totals> 
       <biddiscount> 
        <class>winints/biddiscount</class> 
        <before>subtotal</before> 
       </biddiscount> 
       <globaldiscount> 
        <class>winints/globaldiscount</class> 
        <before>subtotal</before> 
       </globaldiscount> 
      </totals> 
     </quote> 
    </sales> 

GlobalDiscount 클래스, I는 기본 총, 총계, 소계, 모든 업데이트하려고 노력했다. 여전히 정확하게 일치하지 않습니다

내가 뭘 잘못하고 있니?

다른 게시물이 있지만 명확하지 않습니다. 분명히 광고 항목이 총계에서 잘못 계산됩니다. .

답변

1

온라인으로 참조가 올바르지 않습니다. 태그 내에 구성에 이전

  <globaldiscount> 
       <class>winints/globaldiscount</class> 
       <before>subtotal</before> 
      </globaldiscount> 

변화 XML과 가치에

는 "grand_total"당신이 이전 또는 소계 후를 배치하면

<after>grand_total</after> 

해야한다, 당신의 할인은 적용되지 않습니다 총계가 마지막으로 산출되기 때문에 총계의 통지.

그래서 코드가 부분합을 계산할 수는 있지만 계산 한 정확하지 않은 금액은 페이팔에 정확하지 않을 수 있습니다

관련 문제