且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento-创建自定义模块的问题

更新时间:2023-11-30 13:59:34

修改总数始终是困难的部分.除非我在系统中设置了该模块,否则很难在您的代码中找到问题所在.无论如何,我在这里共享了一些代码,用于在结帐过程中修改总计.我尽我所能解释.

Modifying total is always difficult part. And it's hard find out the problem in your code unless I have set up of that module in my system. Anyway here I have shared some codes for modifying total during checkout process. I explained as much I can.

为此,您必须更新很多东西. 报价,地址,订单,Creditmemo,发票,运输,多次运输等.好的,我们开始吧, 首先,我们需要创建名为config.xml的配置文件, config.xml

For this you have to update lot of things. Quote, Address, Order, Creditmemo , Invoice, shipping, multi shipping etc. Okay here we go, First we need to create our configuration file that's called config.xml, config.xml

更新:

<config>
  <modules>
    <VivasIndustries_PercentPayment>
      <version>0.1.0</version>
    </VivasIndustries_PercentPayment>
  </modules>
  <global>
    <helpers>
      <percentpayment>
        <class>VivasIndustries_PercentPayment_Helper</class>
      </percentpayment>
    </helpers>
    <models>
      <percentpayment>
        <class>VivasIndustries_PercentPayment_Model</class>
        <resourceModel>percentpayment_mysql4</resourceModel>
      </percentpayment>
    </models>
    <resources>
      <salesattribute1416562342_setup>
        <setup>
          <module>VivasIndustries_PercentPayment</module>
          <class>Mage_Sales_Model_Mysql4_Setup</class>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </salesattribute1416562342_setup>
      <salesattribute1416562342_write>
        <connection>
          <use>core_write</use>
        </connection>
      </salesattribute1416562342_write>
      <salesattribute1416562342_read>
        <connection>
          <use>core_read</use>
        </connection>
      </salesattribute1416562342_read>
    </resources>
    <events>
    <checkout_type_onepage_save_order_after> <!-- identifier of the event we want to catch -->
        <observers>
          <checkout_type_onepage_save_order_after_discount_handler> <!-- identifier of the event handler -->
            <type>model</type> <!-- class method call type; valid are model, object and singleton -->
            <class>percentpayment/newordertotalobserver</class> <!-- observers class alias -->
            <method>saveDiscountTotal</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </checkout_type_onepage_save_order_after_discount_handler>
        </observers>
      </checkout_type_onepage_save_order_after>     
    <checkout_type_multishipping_create_orders_single> <!-- identifier of the event we want to catch -->
        <observers>     
          <checkout_type_multishipping_create_orders_single_discount_handler> <!-- identifier of the event handler -->
            <type>model</type> <!-- class method call type; valid are model, object and singleton -->
            <class>percentpayment/newordertotalobserver</class> <!-- observers class alias -->
            <method>saveDiscountTotalForMultishipping</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </checkout_type_multishipping_create_orders_single_discount_handler>      
        </observers>
      </checkout_type_multishipping_create_orders_single>
    </events>   
     <sales>
        <quote>
            <totals>                
                <discount_total>
                    <class>percentpayment/quote_address_total_discount</class>
                    <after>subtotal,freeshipping,tax_subtotal,shipping</after>
                    <before>grand_total</before>
                </discount_total> 
            </totals>
        </quote>
            <order_invoice>
                <totals>                
                <discount_total>
                    <class>percentpayment/order_invoice_total_discount</class>
                    <after>subtotal,freeshipping,tax_subtotal,shipping</after>
                    <before>grand_total</before>
                </discount_total> 
                </totals>
            </order_invoice>
            <order_creditmemo>
                <totals>                
                <discount_total>
                    <class>percentpayment/order_creditmemo_total_discount</class>
                    <after>subtotal,freeshipping,tax_subtotal,shipping</after>
                    <before>grand_total</before>
                </discount_total> 
                </totals>
            </order_creditmemo>
    </sales>
  </global>
</config> 

根据此配置更改其他内容.在此之前,请使用phpmyadmin打开core_resources表进入数据库.并删除您的模块条目(如果有的话).就是这样.
如有任何疑问,请在这里评论.

change other things as per this configuration. before that go to your database using phpmyadmin open core_resources table. and delete your module entry if it is there. that's it.
Please comment here, if you have any doubt.