PageRenderTime 53ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/themes/default/views/store/product/view.php

https://gitlab.com/RonLab1987/YupePlusClear
PHP | 265 lines | 247 code | 17 blank | 1 comment | 11 complexity | 25f1566a4514c9445a9b5881f6620d66 MD5 | raw file
  1. <?php
  2. /* @var $product Product */
  3. $this->title = $product->getMetaTitle();
  4. $this->description = $product->getMetaDescription();
  5. $this->keywords = $product->getMetaKeywords();
  6. $this->canonical = $product->getMetaCanonical();
  7. $mainAssets = Yii::app()->getModule('store')->getAssetsUrl();
  8. Yii::app()->getClientScript()->registerScriptFile($mainAssets . '/js/jquery.simpleGal.js');
  9. Yii::app()->getClientScript()->registerCssFile(Yii::app()->getTheme()->getAssetsUrl() . '/css/store-frontend.css');
  10. Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getTheme()->getAssetsUrl() . '/js/store.js');
  11. $this->breadcrumbs = array_merge(
  12. [Yii::t("StoreModule.store", 'Catalog') => ['/store/product/index']],
  13. $product->category ? $product->category->getBreadcrumbs(true) : [],
  14. [CHtml::encode($product->name)]
  15. );
  16. ?>
  17. <div class="row" xmlns="http://www.w3.org/1999/html">
  18. <div class="col-sm-12">
  19. <div class="row">
  20. <div class="col-sm-12">
  21. <h1 class="title"><?= CHtml::encode($product->getTitle()); ?></h1>
  22. </div>
  23. </div>
  24. <div class="row">
  25. <div class="col-sm-12 product-feature">
  26. <div class="row">
  27. <div class="col-sm-4">
  28. <div class="thumbnails">
  29. <div class="image-preview">
  30. <img src="<?= StoreImage::product($product); ?>" id="main-image"
  31. alt="<?= CHtml::encode($product->getImageAlt()); ?>"
  32. title="<?= CHtml::encode($product->getImageTitle()); ?>"
  33. >
  34. </div>
  35. <div class="row">
  36. <div class="col-xs-4 col-md-4">
  37. <a href="<?= $product->getImageUrl(); ?>" class="thumbnail">
  38. <img src="<?= $product->getImageUrl(50, 50); ?>"
  39. alt="<?= CHtml::encode($product->getImageAlt()); ?>"
  40. title="<?= CHtml::encode($product->getImageTitle()); ?>" />
  41. </a>
  42. </div>
  43. <?php foreach ($product->getImages() as $key => $image): { ?>
  44. <div class="col-xs-4 col-md-4">
  45. <a href="<?= $image->getImageUrl(); ?>" class="thumbnail">
  46. <img src="<?= $image->getImageUrl(50, 50); ?>"
  47. alt="<?= CHtml::encode($image->alt) ?>"
  48. title="<?= CHtml::encode($image->title) ?>" />
  49. </a>
  50. </div>
  51. <?php } endforeach; ?>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="col-sm-8">
  56. <?php if($product->isInStock()):?>
  57. <span class="label label-success"><?= Yii::t("StoreModule.store", "In stock");?></span>
  58. <?php if($product->quantity):?>
  59. <span><?= $product->quantity; ?> <?= Yii::t("StoreModule.store", "in stock"); ?></span>
  60. <?php endif;?>
  61. <?php else:?>
  62. <span class="label label-danger"><?= Yii::t("StoreModule.store", "Not in stock");?></span>
  63. <?php endif;?>
  64. <div class="properties">
  65. <?php foreach ($product->getAttributeGroups() as $groupName => $items): { ?>
  66. <div class="propertyGroup">
  67. <h4>
  68. <span><?= CHtml::encode($groupName); ?></span>
  69. </h4>
  70. <table>
  71. <tbody>
  72. <?php
  73. foreach ($items as $attribute): {
  74. $value = $product->attribute($attribute);
  75. if (empty($value)) continue;
  76. ?>
  77. <tr>
  78. <td class="key">
  79. <span><?= CHtml::encode($attribute->title); ?></span>
  80. </td>
  81. <td class="value">
  82. <?= AttributeRender::renderValue($attribute, $product->attribute($attribute)); ?>
  83. </td>
  84. </tr>
  85. <?php } endforeach; ?>
  86. </tbody>
  87. </table>
  88. </div>
  89. <?php } endforeach; ?>
  90. </div>
  91. <br/>
  92. <h4><?= Yii::t("StoreModule.store", "Description"); ?></h4>
  93. <?= $product->short_description; ?>
  94. <?php if($product->getVariantsGroup()):?>
  95. <hr/>
  96. <h4><?= Yii::t("StoreModule.store", "Variants"); ?></h4>
  97. <?php endif;?>
  98. <form action="<?= Yii::app()->createUrl('cart/cart/add'); ?>" method="post">
  99. <input type="hidden" name="Product[id]" value="<?= $product->id; ?>"/>
  100. <?= CHtml::hiddenField(
  101. Yii::app()->getRequest()->csrfTokenName,
  102. Yii::app()->getRequest()->csrfToken
  103. ); ?>
  104. <table class="table table-condensed">
  105. <?php foreach ($product->getVariantsGroup() as $title => $variantsGroup): { ?>
  106. <tr>
  107. <td style="padding: 0;">
  108. <?= CHtml::encode($title); ?>
  109. </td>
  110. <td>
  111. <?=
  112. CHtml::dropDownList(
  113. 'ProductVariant[]',
  114. null,
  115. CHtml::listData($variantsGroup, 'id', 'optionValue'),
  116. ['empty' => '', 'class' => 'form-control', 'options' => $product->getVariantsOptions()]
  117. ); ?>
  118. </td>
  119. </tr>
  120. <?php } endforeach; ?>
  121. </table>
  122. <div>
  123. <input type="hidden" id="base-price" value="<?= round($product->getResultPrice(), 2); ?>"/>
  124. <p>
  125. <?= Yii::t("StoreModule.store", "Price"); ?>:
  126. <?= round($product->getBasePrice(), 2); ?> <?= Yii::t("StoreModule.store", Yii::app()->getModule('store')->currency); ?>
  127. </p>
  128. <p>
  129. <?= Yii::t("StoreModule.store", "Fix price with discount"); ?>:
  130. <?= round($product->getDiscountPrice(), 2); ?>
  131. <?= Yii::t("StoreModule.store", Yii::app()->getModule('store')->currency); ?>
  132. </p>
  133. <p>
  134. <?= Yii::t("StoreModule.store", "Discount"); ?>: <?= round($product->discount); ?>%
  135. </p>
  136. <p>
  137. <?= Yii::t("StoreModule.store", "Total price"); ?>: <span
  138. id="result-price"><?= round($product->getResultPrice(), 2); ?></span>
  139. <?= Yii::t("StoreModule.store", Yii::app()->getModule('store')->currency); ?>
  140. </p>
  141. </div>
  142. <?php if (Yii::app()->hasModule('order')): ?>
  143. <div class="row">
  144. <div class="col-sm-3">
  145. <div class="input-group">
  146. <div class="input-group-btn">
  147. <button class="btn btn-default product-quantity-decrease" type="button">-
  148. </button>
  149. </div>
  150. <input type="text" class="text-center form-control" value="1"
  151. name="Product[quantity]" id="product-quantity"/>
  152. <div class="input-group-btn">
  153. <button class="btn btn-default product-quantity-increase" type="button">+
  154. </button>
  155. </div>
  156. </div>
  157. </div>
  158. <div class="col-sm-6">
  159. <button class="btn btn-success pull-left" id="add-product-to-cart"
  160. data-loading-text="<?= Yii::t("StoreModule.store", "Adding"); ?>">
  161. <?= Yii::t("StoreModule.store", "Add to cart"); ?>
  162. </button>
  163. </div>
  164. </div>
  165. <?php endif; ?>
  166. </form>
  167. <br>
  168. <hr>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. <div class="clearfix"></div>
  174. <ul class="nav nav-tabs" id="myTab">
  175. <?php if (!empty($product->description)): ?>
  176. <li>
  177. <a href="#description" data-toggle="tab"><?= Yii::t("StoreModule.store", "Description"); ?></a>
  178. </li>
  179. <?php endif; ?>
  180. <?php if (!empty($product->data)): ?>
  181. <li><a href="#data" data-toggle="tab"><?= Yii::t("StoreModule.store", "Data"); ?></a></li>
  182. <?php endif; ?>
  183. <li><a href="#attributes" data-toggle="tab"><?= Yii::t("StoreModule.store", "Characteristics"); ?></a></li>
  184. <?php if (Yii::app()->hasModule('comment')): ?>
  185. <li><a href="#comments-tab" data-toggle="tab"><?= Yii::t("StoreModule.store", "Comments"); ?></a></li>
  186. <?php endif; ?>
  187. </ul>
  188. <div class="tab-content">
  189. <?php if (!empty($product->description)): ?>
  190. <div class="tab-pane" id="description">
  191. <?= $product->description; ?>
  192. </div>
  193. <?php endif; ?>
  194. <?php if (!empty($product->data)): ?>
  195. <div class="tab-pane" id="data">
  196. <?= $product->data; ?>
  197. </div>
  198. <?php endif; ?>
  199. <div class="tab-pane" id="attributes">
  200. <table>
  201. <tr>
  202. <td><b><?= Yii::t("StoreModule.store", "Producer"); ?>:</b></td>
  203. <td><?= CHtml::encode($product->getProducerName()); ?></td>
  204. </tr>
  205. <tr>
  206. <td><b><?= Yii::t("StoreModule.store", "SKU"); ?>:</b></td>
  207. <td><?= CHtml::encode($product->sku); ?></td>
  208. </tr>
  209. <tr>
  210. <td><b><?= Yii::t("StoreModule.store", "Length"); ?>:</b></td>
  211. <td><?= round($product->length, 2); ?> <?= Yii::t("StoreModule.store", "m"); ?></td>
  212. </tr>
  213. <tr>
  214. <td><b><?= Yii::t("StoreModule.store", "Width"); ?>:</b></td>
  215. <td><?= round($product->width, 2); ?> <?= Yii::t("StoreModule.store", "m"); ?></td>
  216. </tr>
  217. <tr>
  218. <td><b><?= Yii::t("StoreModule.store", "Height"); ?>:</b></td>
  219. <td><?= round($product->height, 2); ?> <?= Yii::t("StoreModule.store", "m"); ?></td>
  220. </tr>
  221. <tr>
  222. <td><b><?= Yii::t("StoreModule.store", "Weight"); ?>:</b></td>
  223. <td><?= round($product->weight, 2); ?> <?= Yii::t("StoreModule.store", "kg"); ?></td>
  224. </tr>
  225. </table>
  226. </div>
  227. <?php if (Yii::app()->hasModule('comment')): ?>
  228. <div class="tab-pane" id="comments-tab">
  229. <?php $this->widget('application.modules.comment.widgets.CommentsWidget', [
  230. 'redirectTo' => ProductHelper::getUrl($product),
  231. 'model' => $product,
  232. ]); ?>
  233. </div>
  234. <?php endif; ?>
  235. </div>
  236. </div>
  237. <div class="col-sm-12">
  238. <?php $this->widget('application.modules.store.widgets.LinkedProductsWidget', ['product' => $product, 'code' => null,]); ?>
  239. </div>
  240. </div>
  241. <?php Yii::app()->getClientScript()->registerScript(
  242. "product-images",
  243. <<<JS
  244. $(".thumbnails").simpleGal({mainImage: "#main-image"});
  245. $("#myTab li").first().addClass('active');
  246. $(".tab-pane").first().addClass('active');
  247. JS
  248. ); ?>