如何添加更多字段以在magento中共享心愿单?

时间:2014-08-01 10:20:48

标签: php forms magento

我在Magento 1.9中改变了我的共享愿望清单表格,我找到了我的愿望清单的表格,基本上是一个电子邮件地址框和一个消息框,iv删除了电子邮箱并放入一个隐藏的输入表单只发送wishlist到一个地址,现在有效我试图添加名称,地址,电话号码,邮政编码等,但没有看,我会尝试找到处理发送电子邮件的表单的脚本但行动是getSendURL() ?>所以不是很有帮助我已经尝试用带有消息id的输入改变textarea消息,但没有运气如何实现这个想法?

<div class="page-title">
<h1><?php echo $this->__('Share Your Wishlist') ?></h1>
</div>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<form action="<?php echo $this->getSendUrl() ?>" id="form-validate" method="post">
<div class="fieldset">
    <?php echo $this->getBlockHtml('formkey')?>
    <h2 class="legend"><?php echo $this->__('Sharing Information') ?></h2>
    <ul class="form-list">
        <li class="wide">

            <div class="input-box">
                <input type="hidden" name="emails" id="email_address" value="sample@gmail.com"/>
                <!--<textarea name="emails" cols="60" rows="5" id="email_address" class="validate-emails required-entry"><?php echo $this->getEnteredData('emails') ?></textarea>/-->
            </div>
        </li>
        <li class="wide">
            <label for="message"><?php echo $this->__('Message') ?></label>
            <div class="input-box">
                <textarea id="message" name="message" cols="60" rows="5"><?php echo $this->getEnteredData('message') ?></textarea>
            </div>
        </li>
        <?php if($this->helper('wishlist')->isRssAllow()): ?>
        <li class="control">
            <div class="input-box">
                <input type="checkbox" name="rss_url" id="rss_url" value="1" title="<?php echo $this->__('Check this checkbox if you want to add a link to an rss feed to your wishlist.') ?>" class="checkbox" />
            </div>
            <label for="rss_url"><?php echo $this->__('Check this checkbox if you want to add a link to an rss feed to your wishlist.') ?></label>
        </li>
        <?php endif; ?>
    </ul>
</div>
<div class="buttons-set form-buttons">
    <p class="required"><?php echo $this->__('* Required Fields') ?></p>
    <p class="back-link"><a href="<?php echo $this->getBackUrl(); ?>"><small>&laquo; </small><?php echo $this->__('Back')?></a></p>
    <button type="submit" title="<?php echo $this->__('Share Wishlist') ?>" class="button"><span><span><?php echo $this->__('Share Wishlist') ?></span></span></button>
</div>
</form>

1 个答案:

答案 0 :(得分:0)

我已经想出了如何在愿望清单表格中添加其他字段,你需要转到你的IndexController.php,它位于app / code / core / Mage / Wishlist / controllers / IndexController.php转到第627行应该是一个变量

$message = nl2br(htmlspecialchars((string) $this->getRequest()->getPost('message')));

下面添加您已添加到心愿单表格中的变量,如姓名地址等。

$title =            $_POST['title'];
$first_name =       $_POST['first_name'];
$surname =          $_POST['surname'];
$email2 =           $_POST['email'];
$phone =            $_POST['phone'];
$housenamenumber =  $_POST['housenamenumber'];
$streetname =       $_POST['streetname'];
$city =             $_POST['city'];
$postcode =         $_POST['postcode'];

然后一旦你添加了它们转到第690行并找到

array(
                    'customer'       => $customer,
                    'salable'        => $wishlist->isSalable() ? 'yes' : '',
                    'items'          => $wishlistBlock,
                    'addAllLink'     => Mage::getUrl('*/shared/allcart', array('code' => $sharingCode)),
                    'viewOnSiteLink' => Mage::getUrl('*/shared/index', array('code' => $sharingCode)),
                    'message'        => $message,
                    'title'          => $title,
                    'firstname'      => $first_name,
                    'surname'        => $surname,
                    'email2'         => $email2,
                    'phone'          => $phone,
                    'housenamenumber'=> $housenamenumber,
                    'streetname'     => $streetname,
                    'city'           => $city,
                    'postcode'       => $postcode,


                )

并相应地调整它们,之后更改您的电子邮件模板并添加{{var firstname}}等等,它可以解决任何问题,请不要犹豫。