[Magento] Appeler une fonction dans une autre
Salut les amis,
je bosse en ce moment sur Magento, et j ai un petit problème.
En fait j'ai écris un code pour envoyer un formulaire lorsqu'on veut acheter un produit (dans le style contact us) et à cela j aimerai ajouter dans le même formulaire une option externe qui se trouve dans un autre template (select.phtml) celui ci affiche le custom option d'un produit.
pour être plus explicite, j'aimerai insérer le custom option de ce produit dans le formulaire d'envoi.
je ne sais pas si quelqu'un un peut me donne un coup de main à ce niveau, merci.
Voici le code du custom option: select.phtml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <?php /* @var $this Mage_Catalog_Block_Product_View_Options_Type_Select */ ?>
<?php $_option = $this->getOption() ?>
<dt><label<?php if ($_option->getIsRequire()) echo ' class="required"' ?>><?php if ($_option->getIsRequire()) echo '<em>*</em>' ?><?php echo $this->htmlEscape($_option->getTitle()) ?></label></dt>
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<?php echo $this->getValuesHtml() ?>
<?php if ($_option->getIsRequire()): ?>
<?php if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO): ?>
<span id="options-<?php echo $_option->getId() ?>-container"></span>
<?php endif; ?>
<?php endif;?>
</div>
</dd> |
et voici le code de mon formulaire: formulaire.phtml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| button type="button" title="<?php echo $this->__('Application Form') ?>" class="button" onclick="new
Effect.toggle('text');"><span><span><?php echo $this->__('Application Form') ?></span></span></button>
<div id="text" style="display:none">
<div class="page-title">
<h1><?php echo Mage::helper('contacts')->__('Contact Us for ') ?>
<class="product-name"><title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this-
>htmlEscape($_product->getName())?></h1>
</div>
<form action="<?php echo Mage::getUrl();?>/contacts/index/post/" id="contactForm" method="post">
<div class="fieldset">
<div class="field name-company">
<p><label for="company"><?php echo Mage::helper('contacts')->__('Company') ?></label> </p>
<input size="57" name="company" id="company" title="<?php echo Mage::helper('contacts')->__('Company') ?
>"value="" class="input-text" type="text" />
</div>
<div class="field name-customer-id">
<p><label for="customer-id"><?php echo Mage::helper('contacts')->__('CustomerID') ?></label> </p>
<input size="57" name="customer-id" id="customer-id" title="<?php echo Mage::helper('contacts')->__
('CustomerID') ?>"value="" class="input-text" type="text" />
</div>
<p></p>
<div class="field name-title">
<div class="input-box">
<label for="title"><?php echo Mage::helper('contacts')->__('Title:') ?><span></span></label>
<?php $userTitle = $this->htmlEscape($this->helper('contacts')->getUserTitle());
$formTitel = Mage::helper('contacts')->__('Title');
?>
<input name="title" id="title" title="<?php echo $formTitel ?>" value="<?php echo $userTitle ?>" <?php echo
($userTitle == 'Mr')? "checked" : ""; ?> type="radio"> Mr
<input name="title" id="title" title="<?php echo $formTitel ?>" value="<?php echo $userTitle ?>" <?php echo
($userTitle == 'Mrs')? "checked" : ""; ?> type="radio"> Mrs<br>
</div>
</div>
<p></p>
<div class="field name-firstname">
<p><label for="firstname" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('First Name')
?></label></p>
<input size="57" name="firstname" id="firstname" title="<?php echo Mage::helper('contacts')->__('First
Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserFirstName()) ?>"
class="input-text required-entry" type="text" />
</div>
<div class="field name-lastname">
<p> <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Last Name') ?
></label></p>
<input size="57" name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Last Name') ?>"
value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserLastName()) ?>" class="input-text
required-entry" type="text" />
</div>
<div class="field name-email">
<p> <label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?
></label> </p>
<input size="57" name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>"
value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="input-text
required-entry validate-email" type="text" />
</div>
<input name="hideit" id="hideit" value="" style="display:none !important;" type="text"/>
<div class="buttons-set">
<p class="back-link"><a href="<?php echo $this->getBackUrl() ?>" class="back-link"><small>«
</small><?php echo $this->__('Back') ?></a></p>
<button type="submit" title="<?php echo Mage::helper('contacts')->__('Send') ?>"
class="button"><span><span><?php echo Mage::helper('contacts')->__('Send') ?></span></span></button>
<!-- <button type="button" title="<?php echo Mage::helper('contacts')->__('Back') ?>" class="button"
onclick="new Effect.BlindUp('text')"><span><span><?php echo Mage::helper('contacts')->__('Back') ?
></span></span></button> -->
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
</div>
</form>
</div> |