Jump to content
Sign in to follow this  
retrojdev

Как вывести первую цену опции на главную OpenCart?

Recommended Posts

Основная цена товара у меня - это опции, а основная цена ОС стоит равна 0. Как правильно вывести из опции стоимость товара?

Вот это отвечает за цену на главной странице:

        <?php if ($product['price']) { ?>
        <div class="price">
          <?php if (!$product['special']) {  ?>
            <span class="price-new"><?php echo $product['price']; ?></span>
            <?php if( preg_match( '#(\d+).?(\d+)#',  $product['price'], $p ) ) { ?> 
            <?php } ?>
          <?php } else { ?>
            <span class="price-new"><?php echo $product['special']; ?></span><br>
            <span class="price-old"><?php echo $product['price']; ?></span> 
            <?php if( preg_match( '#(\d+).?(\d+)#',  $product['special'], $p ) ) { ?> 
            <?php } ?>

А это как у меня внутри товара:

            <?php if ($options) { ?>
                <h3 class="product"><?php echo $text_option; ?></h3>
                <?php foreach ($options as $option) { ?>
                    <?php if ($option['type'] == 'select') { ?>
                        <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                            <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
                            <select name="option[<?php echo $option['product_option_id']; ?>]" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control">
                                <?php foreach ($option['product_option_value'] as $option_value) { ?>
                                    <option value="<?php echo $option_value['product_option_value_id']; ?>"  points="<?php echo (isset($option_value['points_value']) ? $option_value['points_value'] : 0); ?>" price_prefix="<?php echo $option_value['price_prefix']; ?>" price="<?php echo $option_value['price_value']; ?>"><?php echo $option_value['name']; ?>
                                        <?php if ($option_value['price']) { ?>
                                          <?php
                                          if ($option_value['price_prefix'] == '*') {
                                            if ($option_value['price_value'] != 1.0)
                                              printf("(%+d%%)", round(($option_value['price_value'] * 100) - 100) );
                                          } else {
                                            echo "(".$option_value['price'].")";
                                          }
                                          ?>
                                        <?php } ?>
                                    </option>
                                <?php } ?>
                            <option value=""><?php echo $text_select; ?></option>
                            </select>
                        </div>
                    <?php } ?>
Как правильно вывести главную цену опции на главной? Делаю с помощью: 
<?php echo $option_value['price']; ?>

и

$option['product_option_value'][0]['price']
Получается просто пустота, без цены...)
Edited by retrojdev

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.