shipping-calculator.phtml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * this partial is to be used on the listing details page,
  4. * as well as on the invoice confirmation and shopping cart view pages
  5. * and basically anywhere where we need a postage calculator box.
  6. *
  7. * prerequisites:
  8. * - the listing must exist in the listings table,
  9. * meaning that the calculator wont work for the listing preview page
  10. *
  11. * required input:
  12. * - user model [ the seller ]
  13. * - listing id
  14. *
  15. * accepted input:
  16. * - locationId
  17. * - postCode
  18. * - quantity (for a single calculation)
  19. *
  20. * result:
  21. * - a table with all available postage options, or an error message output by the calculatePostage() method.
  22. */
  23. $shippableLocations = $user->getShipping()->getShippableLocations(true);
  24. if (count($shippableLocations) > 0) { ?>
  25. <div id="postage-calculator">
  26. <?php echo $this->formElement('hidden', 'enableSelection', $this->enableSelection)
  27. ->render();
  28. ?>
  29. <?php echo $this->formElement('hidden', 'ids', $this->listingId)
  30. ->setAttributes(array('class' => 'ids'))
  31. ->render();
  32. ?>
  33. <dl class="dl-horizontal">
  34. <dt><?php echo $this->_('Select Country'); ?></dt>
  35. <dd><?php echo $this->formElement('select', 'locationId', $this->locationId)
  36. ->setAttributes(array('class' => 'form-control input-medium'))
  37. ->setMultiOptions($shippableLocations)
  38. ->render();
  39. ?>
  40. </dd>
  41. <dt><?php echo $this->_('Zip/Post Code'); ?></dt>
  42. <dd><?php echo $this->formElement('text', 'postCode', $this->postCode)
  43. ->setAttributes(array('class' => 'form-control input-small'))
  44. ->render();
  45. ?>
  46. </dd>
  47. <?php if (!empty($quantity) && !is_array($quantity)) { ?>
  48. <dt><?php echo $this->_('Quantity'); ?></dt>
  49. <dd><?php echo $this->formElement('text', 'quantity', $this->quantity)
  50. ->setAttributes(array('class' => 'form-control input-mini qty'))
  51. ->render();
  52. ?>
  53. </dd>
  54. <?php
  55. }
  56. else if (is_array($quantity)) {
  57. ?>
  58. <?php echo $this->formElement('hidden', 'quantity', $this->quantity)
  59. ->setAttributes(array('class' => 'qty'))
  60. ->render();
  61. ?>
  62. <?php } ?>
  63. <dd>
  64. <?php echo $this->formElement('button', 'button', $this->_('Get Shipping Rates'))
  65. ->setAttributes(array(
  66. 'class' => 'btn btn-default',
  67. 'id' => 'calculate-postage',
  68. 'data-loading-text' => $this->_('Please wait ...')))
  69. ->render();
  70. ?>
  71. </dd>
  72. </dl>
  73. <div class="result">
  74. </div>
  75. </div>
  76. <?php } ?>