1

I have two extensions(Comment and Date) created by following this tutorial. They add a new field to one page checkout. Everything went fine unless I tried to put the values from both fields into one 'order confirmation' email template.

The problem is that one extension echoes its value and the other not - but only in emails. On admin or frontend pages they both echo their values respectively.

To print the values in email templates I use:

{{depend order.hasCommentField()}}
{{var order.getCommentFieldHtml()}}

and:

{{depend order.hasDateField()}}
{{var order.getDateFieldHtml()}}

Comment's config.xml where models rewrite is defined:

<global>
 <models>
  <sales>
   <rewrite>
    <order>Beph_Comment_Model_Sales_Order</order>
   </rewrite>
  </sales>
(...)

Date's config.xml where models rewrite is defined:

<global>
 <models>
  <sales>
   <rewrite>
    <order>Beph_Date_Model_Sales_Order</order>
   </rewrite>
  </sales>
(...)

Comment's Beph/Comment/Model/Sales/Order.php:

<?php
class Beph_Comment_Model_Sales_Order extends Mage_Sales_Model_Order{
 public function hasCommentField(){
    $var = $this->getComment();
    if($var && !empty($var)){
        return true;
    }else{
        return false;
    }
 }
 public function getCommentFieldHtml(){
    $var = $this->getComment();
    return $var;
 }
}

Date's Beph/Date/Model/Sales/Order.php:

<?php
class Beph_Date_Model_Sales_Order extends Mage_Sales_Model_Order{
 public function hasDateField(){
    $var = $this->getDate();
    if($var && !empty($var)){
        return true;
    }else{
        return false;
    }
 }
 public function getDateFieldHtml(){
    $var = $this->getDate();
    return $var;
 }
}

I tried renaming 'sales' in one module(with class names and folders) but to no avail. Is it possible that these two modules are in conflict(since they rewrite same model)? If so how would I fix it? Thanks.

3

Take a look at How to prevent module rewrite class conflict in Magento you seem to have a conflict

Try

Comment's config.xml where models rewrite is defined:

<global>
 <models>
  <!--sales> <-- remove
   <rewrite>
    <order>Beph_Comment_Model_Sales_Order</order>
   </rewrite>
  </sales-->
(...)

Date's config.xml where models rewrite is defined:

<global>
 <models>
  <sales>
   <rewrite>
    <order>Beph_Date_Model_Sales_Order</order>
   </rewrite>
  </sales>
(...)

Comment's Beph/Comment/Model/Sales/Order.php:

<?php
class Beph_Comment_Model_Sales_Order extends Beph_Date_Model_Sales_Order{
 public function hasCommentField(){
    $var = $this->getComment();
    if($var && !empty($var)){
        return true;
    }else{
        return false;
    }
 }
 public function getCommentFieldHtml(){
    $var = $this->getComment();
    return $var;
 }
}

Date's Beph/Date/Model/Sales/Order.php:

<?php
class Beph_Date_Model_Sales_Order extends Mage_Sales_Model_Order{
 public function hasDateField(){
    $var = $this->getDate();
    if($var && !empty($var)){
        return true;
    }else{
        return false;
    }
 }
 public function getDateFieldHtml(){
    $var = $this->getDate();
    return $var;
 }
}

Also since both module seem to do similar things, you may consider merging them

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.