Ocena zakupionych produktów


3194
Pozwól klientom oceniać produkty, które faktycznie kupili.

Znajdź w catalog/product_reviews_write.php
<?php
  if ($messageStack->size('review') > 0) {
      echo $messageStack->output('review');
  }
?>

Dodaj przed:

<?php
// ##### Start: Products Review Write Check
        // see if this person has left a review
    $query_allready = tep_db_query("select reviews_id from reviews where products_id = '" . (int)$product_info['products_id'] . "' AND customers_id = '" . (int)$customer_id . "'");
    if (tep_db_num_rows($query_allready) > 0)
        {
        $error = true;
?>
            <div class="col-sm-12 mb-4 w3-center"><div class="w3-border w3-border-green w3-pale-green w3-padding"><?php echo REVIEWS_CUSTOMER_ALREDY_REVIEWD_INFO_TITLE;?></div></div>
    <?php }else{

        // see if this customer purchased the product
        // only if not test account then we check this
        $b_bought_product = false;
        // grab all orders by this customer
        $query = tep_db_query("select orders_id from orders where customers_id = '" . (int)$customer_id . "'");

        // check all orders from this customer
        if (tep_db_num_rows($query) > 0)
        {
            // if they have, check orders
            while ($arr_order_ids = tep_db_fetch_array($query))
            {
                $order_id_curr = $arr_order_ids['orders_id'];
                // for this order_id, iterate through products and compare products_ids the one being reviewed
                $products_id_of_order_query = tep_db_query("select products_id from orders_products where orders_id = '" . (int)$order_id_curr . "'");
                while ($arr_product_ids = tep_db_fetch_array($products_id_of_order_query))
                {
                    $products_id_curr = $arr_product_ids['products_id'];
                    if ($products_id_curr == $product_info['products_id'])
                    {
                        $b_bought_product = true;
                    }
                }
            }
        }

        if (!$b_bought_product)
        {
        $error = true;
?>
        <div class="col-sm-12 mb-4 w3-center"><div class="w3-border w3-border-red w3-sand w3-padding"><?php echo REVIEWS_CUSTOMER_NOT_PURCHASED_TITLE;?></div></div>
<?php }else{ /* (Start: Products Review Write Check) */ ?>

Znajdź:

  <div class="buttonSet">
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', null, 'primary'); ?></span>

    <?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params(array('reviews_id', 'action')))); ?>
  </div>
</div>

</form>

Dodaj poniźej:

<?php /* (Start: Products Review Write Check) */
   }    
  }
// ##### END: Product Reviews Write Check
?>

Dodaj pliku językowego: catalog/includes/languages/polish/product_reviews_write.php

define('REVIEWS_CUSTOMER_ALREDY_REVIEWD_TITLE', '<span class="w3-text-black">Nie można już oceniać. Oceniłeś już ten produkt.</span>');
define('REVIEWS_CUSTOMER_NOT_PURCHASED_TITLE', '<span class="w3-text-black">Brak możliwości oceny. Jeszcze nie kupiłeś tego produktu.</span>');

##################

Znajdź w: catalog/product_reviews.php

<div class="buttonSet">
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_WRITE_REVIEW, 'comment', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, tep_get_all_get_params()), 'primary'); ?></span>

    <?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params())); ?>
  </div>
</div>

Zmień na:

<div class="buttonSet row">

<?php if ($product_info['products_reviews_status'] == '0'){
if (isset($_SESSION['customer_id'])) {
// ##### Start: Products Review Write Check
        // see if this person has left a review
    $query_allready = tep_db_query("select reviews_id from reviews where products_id = '" . (int)$product_info['products_id'] . "' AND customers_id = '" . (int)$customer_id . "'");
    if (tep_db_num_rows($query_allready) > 0)
        {
        $error = true;

  if ($messageStack->size('product_reviews') > 0) {?>
            <div class="col-sm-12 mb-2 w3-center"><div class="w3-border w3-border-green w3-pale-green w3-round w3-padding"><?php echo REVIEWS_CUSTOMER_ALREDY_REVIEWD_INFO_TITLE;?></div></div>
<?php }else{
    ?>
            <div class="col-sm-12 mb-2 w3-center"><div class="w3-border w3-border-green  w3-sand w3-padding"><?php echo REVIEWS_CUSTOMER_ALREDY_REVIEWD_TITLE;?></div></div>
    <?php }}else{

        // see if this customer purchased the product
        // only if not test account then we check this
        $b_bought_product = false;
        // grab all orders by this customer
        $query = tep_db_query("select orders_id from orders where customers_id = '" . (int)$customer_id . "'");

        // check all orders from this customer
        if (tep_db_num_rows($query) > 0)
        {
            // if they have, check orders
            while ($arr_order_ids = tep_db_fetch_array($query))
            {
                $order_id_curr = $arr_order_ids['orders_id'];
                // for this order_id, iterate through products and compare products_ids the one being reviewed
                $products_id_of_order_query = tep_db_query("select products_id from orders_products where orders_id = '" . (int)$order_id_curr . "'");
                while ($arr_product_ids = tep_db_fetch_array($products_id_of_order_query))
                {
                    $products_id_curr = $arr_product_ids['products_id'];
                    if ($products_id_curr == $product_info['products_id'])
                    {
                        $b_bought_product = true;
                    }
                }
            }
        }

        if (!$b_bought_product)
        {
        $error = true;?>
        
            <div class="col-sm-12 mb-2 w3-center"><div class="w3-border w3-border-red  w3-sand w3-padding"><?php echo REVIEWS_CUSTOMER_NOT_PURCHASED_TITLE;?></div></div>
      <?php }else{?>
            <div class="col-sm-12 mb-2"><?php echo tep_draw_button(IMAGE_BUTTON_WRITE_REVIEW, 'fas fa-comment-alt', tep_href_link('product_reviews_write.php', tep_get_all_get_params()), 'primary', NULL, 'btn btn-success btn-block');?></div>

        <?php
        }    
      }
// ##### END: Product Reviews Write Check
?>
<?php }else{?>
    <div class="col-sm-12 mt-2 mb-2 w3-center"><div class="w3-padding w3-border w3-sand">
    <div class=""><?php echo REVIEWS_CUSTOMER_LOGIN_TITLE;?><hr class="hr-gr mt-2 mb-2"></div>
    <div class=""><?php echo tep_draw_button(REVIEWS_CUSTOMER_BUTTON_LOGIN_TITLE, 'fa fa-user-alt', tep_href_link('product_reviews_write.php', tep_get_all_get_params()), 'primary', NULL, 'btn btn-info btn-block'); ?></div>
    <div class="clearfix"></div></div></div>
<?php }}?>

Dodaj pliku językowego: catalog/includes/languages/polish/product_reviews.php

define('REVIEWS_CUSTOMER_LOGIN_TITLE', '<b class="w3-text-black">Tylko dla zarejestrowanych klientów.</b><br><span class="w3-small">Musisz także kupić ten produkt, aby móc go ocenić.</span>');
define('REVIEWS_CUSTOMER_ALREDY_REVIEWD_TITLE', '<b class="w3-text-black">Nie można już oceniać. Oceniłeś już ten produkt.</span>');
define('REVIEWS_CUSTOMER_ALREDY_REVIEWD_INFO_TITLE', '<span class="w3-text-black">Dziękujemy za opinię. Zostało do nas przesłane i wkrótce powinno zostać aktywowane.</span>');
define('REVIEWS_CUSTOMER_NOT_PURCHASED_TITLE', '<span class="w3-text-black">Brak możliwości oceny. Jeszcze nie kupiłeś tego produktu.</span>');
define('REVIEWS_CUSTOMER_BUTTON_LOGIN_TITLE', 'Proszę się zalogować');


##################

Kod do recenzji produktów w strefie klienta. W tej sekcji możesz pokazać klientowi listę wszystkich wcześniej zakupionych produktów, które można ocenić. Jest to realizowane w dowolnym miejscu w obszarze klienta.

Wyświetlane są wszystkie zakupione produkty. Produkty niedostępne są oznaczone osobno. Produkty, które zostały już ocenione, wyświetlane są w osobnym polu.


Dodaj do: catalog/account.php

<?php
  $customer_total_prod_query = tep_db_query("select o.customers_id, op.products_name, op.products_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . $_SESSION['customer_id'] . "' and o.orders_id = op.orders_id and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.public_flag = '1' group by op.products_name order by op.products_name ASC");
    if (tep_db_num_rows($customer_total_prod_query) > 0)
        {

$reviewed_count_query = tep_db_query("select count(r.products_id) as count from reviews r left join products p on r.products_id = p.products_id where customers_id = '" . $_SESSION['customer_id'] . "' and p.products_reviews_status = '0' and p.products_status = '1'");
$reviewed_count = tep_db_fetch_array($reviewed_count_query);
$count = $reviewed_count['count'];

$reviewed_count_plus_query = tep_db_query("select count(r.products_id) as count from reviews r left join products p on r.products_id = p.products_id where customers_id = '" . $_SESSION['customer_id'] . "' and p.products_reviews_status = '0'");
$reviewed_count_plus = tep_db_fetch_array($reviewed_count_plus_query);
$count_plus = $reviewed_count_plus['count'];

$customer_count_revcount_query = tep_db_query("select o.customers_id, op.products_name, op.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . $_SESSION['customer_id'] . "' and p.products_id = op.products_id and o.orders_id = op.orders_id and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.public_flag = '1' and p.products_status = '1' and p.products_reviews_status = '0' group by op.products_name order by op.products_name ASC");
$customer_count_revcount = tep_db_num_rows($customer_count_revcount_query) - $count;
?>
<header class="w3-camo-forest w3-padding w3-xlarge"><i class="fa fa-star w3-text-yellow" style="text-shadow: 1px 0 #fff, 0 -1px transparent, -1px 0 #fff, 0 1px #fff"></i> <?php echo MY_ACCOUNT_REVIEW_NOW_PRODUCTS . ' ' . $customer_count_revcount;?></header>
<div class="w3-border mb-4"><div class="clearfix"></div><hr class="hr-trans mb-1 mt-2">
<div class="w3-padding"><div class="w3-border w3-border-red w3-padding mb-2 w3-text-red w3-pale-red"><?php echo MY_ACCOUNT_REVIEW_PRODUCTS_TODAY_NO_AVALIABLE_HEADER_INFO;?></div><div class="clearfix"></div><hr class="hr-gr mb-1 mt-1"></div>
<?php
$query_allready_rows = '';
  $customer_reviews_query = tep_db_query("select o.customers_id, op.products_name, op.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . $_SESSION['customer_id'] . "' and p.products_id = op.products_id and o.orders_id = op.orders_id and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.public_flag = '1' and p.products_reviews_status = '0' group by op.products_name order by op.products_name ASC");
  while ($customer_reviews = tep_db_fetch_array($customer_reviews_query)){
$query_allready_rows++;
if (strlen($query_allready_rows) < 1) {
$query_allready_rows = '0' . $query_allready_rows;
}

$products_revd_status_query = tep_db_query("select products_status from products where products_id = '" . $customer_reviews['products_id'] . "'");
$products_revd_status = tep_db_fetch_array($products_revd_status_query);

    $query_allready = tep_db_query("select reviews_id from reviews r left join products p on r.products_id = p.products_id where r.products_id = '" . (int)$customer_reviews['products_id'] . "' AND customers_id = '" . (int)$_SESSION['customer_id'] . "' and p.products_reviews_status = '0'");
    if (tep_db_num_rows($query_allready) > 0)
        {
        $error = true;
}else{
?>
<div class="col-sm-6">
<?php
$printlist_category_query = tep_db_query("select c.categories_id, c.categories_product_qty, c.category_stock_status, c.category_stock_info_status, c.cat_stock_att_image, cd.categories_id, cd.categories_name, cd.categories_stock, cd.categories_stock_alternatively, cd.categories_stock_replacement from products p, categories c, categories_description cd, products_to_categories pc where p.products_id = '" . $customer_reviews['products_id'] . "' and p.products_id = pc.products_id and pc.categories_id = cd.categories_id and cd.categories_id = c.categories_id and cd.language_id = '" . (int)$languages_id . "'");
$printlist_category = tep_db_fetch_array($printlist_category_query);
?>
<?php if ($products_revd_status['products_status'] == '1'){?>
<div class="mb-1 mt-1 w3-padding w3-border w3-border-red w3-sand">
<?php }else{?>
<div class="mb-1 mt-1 w3-padding w3-border w3-border-red w3-pale-red">
<?php } if ($products_revd_status['products_status'] == '1'){?>
<a rel="preconnect" itemprop="url" href="<?php
if (SHOW_EXTENDED_BROWSER_ADDRESS == 'True'){
$originalpnlString = $customer_reviews['products_name'];
$outputpnlString = '=' . $printlist_category['categories_name'] . '-' . preg_replace('/s+/', '-', $originalpnlString);
}else{
$outputpnlString = '';
}
echo tep_href_link('product_info.php', 'products_id=' . $customer_reviews['products_id']) . $outputpnlString; ?>"><span class="w3-text-teal w3-hover-text-black"><?php echo $query_allready_rows . ' ' . $customer_reviews['products_name'];?></span></a>
<?php }else{?>
<span class="w3-text-red"><?php echo $query_allready_rows . ' ' . $customer_reviews['products_name'];?></span>
<?php }?>

<?php if ($products_revd_status['products_status'] == '1'){?>
<span class="pull-right hidden-xs hidden-sm"><?php echo tep_draw_button(MY_ACCOUNT_REVIEW_PRODUCTS_LG_MD, 'fa fa-pencil-alt', tep_href_link('product_reviews_write.php', 'products_id=' . $customer_reviews['products_id'] . $outputpnlString), 'primary', NULL, 'btn btn-info btn-xs'); ?></span>
<span class="pull-right hidden-md hidden-lg"><?php echo tep_draw_button(MY_ACCOUNT_REVIEW_PRODUCTS_SM_XS, 'fa fa-pencil-alt', tep_href_link('product_reviews_write.php', 'products_id=' . $customer_reviews['products_id'] . $outputpnlString), 'primary', NULL, 'btn btn-info btn-xs'); ?></span>
<?php }else{?>
<span class="pull-right"><span class="w3-border w3-border-red w3-white w3-padding-small"><i class="fa fa-minus-circle w3-text-red"></i></span></span>
<?php }?>
</div>
</div>
<?php
}
}?>
<?php }else{?>
<header class="w3-red w3-padding w3-xlarge"><i class="fa fa-star w3-text-yellow" style="text-shadow: 1px 0 #fff, 0 -1px transparent, -1px 0 #fff, 0 1px #fff"></i> <?php echo MY_ACCOUNT_REVIEW_NOW_PRODUCTS;?></header>
<div class="w3-border mb-4"><div class="clearfix"></div><hr class="hr-trans mb-1 mt-2">
<div class="w3-padding"><?php echo MY_ACCOUNT_REVIEW_NO_PRODUCTS_FOR_REVIEW;?></div>
<?php }?>
<div class="clearfix"></div><hr class="hr-trans mb-2 mt-1">
</div>

<?php
  $customer_no_reviews_prod_query = tep_db_query("select o.customers_id, op.products_name, op.products_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . $_SESSION['customer_id'] . "' and o.orders_id = op.orders_id and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.public_flag = '1' group by op.products_name order by op.products_name ASC");
  $customer_no_reviews_prod = tep_db_fetch_array($customer_no_reviews_prod_query);

    $query_allready_prod_reviewed = tep_db_query("select reviews_id from reviews where products_id = '" . (int)$customer_no_reviews_prod['products_id'] . "' AND customers_id = '" . (int)$_SESSION['customer_id'] . "'");
    if (tep_db_num_rows($query_allready_prod_reviewed) > 0)
        {
?>
<header class="w3-camo-forest w3-padding w3-xlarge"><?php echo MY_ACCOUNT_PRODUCTS_REVIEWED . ' ' . $count_plus;?></header>
<div class="w3-border mb-4"><div class="clearfix"></div><hr class="hr-trans mb-2 mt-2">

<?php
$query_no_allready_rows = '';
  $customer_no_reviews_query = tep_db_query("select o.customers_id, op.products_name, op.products_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . $_SESSION['customer_id'] . "' and o.orders_id = op.orders_id and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.public_flag = '1' group by op.products_name order by op.products_name ASC");
  while ($customer_no_reviews = tep_db_fetch_array($customer_no_reviews_query)){
$query_no_allready_rows++;
if (strlen($query_no_allready_rows) < 1) {
$query_no_allready_rows = '0' . $query_no_allready_rows;
}

$products_status_query = tep_db_query("select products_status from products where products_id = '" . $customer_no_reviews['products_id'] . "'");
$products_status = tep_db_fetch_array($products_status_query);

    $query_allready_reviewed = tep_db_query("select reviews_id from reviews r left join products p on r.products_id = p.products_id where r.products_id = '" . (int)$customer_no_reviews['products_id'] . "' AND customers_id = '" . (int)$_SESSION['customer_id'] . "' and p.products_reviews_status = '0'");
    if (tep_db_num_rows($query_allready_reviewed) > 0)
        {
    while ($allready_reviewed = tep_db_fetch_array($query_allready_reviewed)){
?>
<div class="col-sm-6">

<?php if ($products_status['products_status'] == '1'){?>
<div class="mb-1 mt-1 w3-padding w3-border w3-border-green w3-food-pistachio">
<?php }else{?>
<div class="mb-1 mt-1 w3-padding w3-border w3-border-red w3-pale-red">
<?php }?>
<?php
$printlist_norev_category_query = tep_db_query("select c.categories_id, c.categories_product_qty, c.category_stock_status, c.category_stock_info_status, c.cat_stock_att_image, cd.categories_id, cd.categories_name, cd.categories_stock, cd.categories_stock_alternatively, cd.categories_stock_replacement from products p, categories c, categories_description cd, products_to_categories pc where p.products_id = '" . $customer_no_reviews['products_id'] . "' and p.products_id = pc.products_id and pc.categories_id = cd.categories_id and cd.categories_id = c.categories_id and cd.language_id = '" . (int)$languages_id . "'");
$printlist_norev_category = tep_db_fetch_array($printlist_norev_category_query);
?>
<?php if ($products_status['products_status'] == '1'){?>
<a rel="preconnect" itemprop="url" href="<?php
if (SHOW_EXTENDED_BROWSER_ADDRESS == 'True'){
$originalnorevString = $customer_no_reviews['products_name'];
$outputnorevString = '=' . $printlist_norev_category['categories_name'] . '-' . preg_replace('/s+/', '-', $originalnorevString);
}else{
$outputnorevString = '';
}
echo tep_href_link('product_info.php', 'products_id=' . $customer_no_reviews['products_id']) . $outputnorevString; ?>"><span class="w3-text-teal w3-hover-text-black"><?php echo $query_no_allready_rows . ' ' . $customer_no_reviews['products_name'];?></span></a>
<?php }else{?>
<span class="w3-text-red"><?php echo $query_no_allready_rows . ' ' . $customer_no_reviews['products_name'];?></span>
<?php }?>
<span class="pull-right">
<a rel="preconnect" itemprop="url" href="<?php echo tep_href_link('product_reviews.php', 'products_id=' . $customer_no_reviews['products_id']) . $outputnorevString; ?>">
<?php if ($products_status['products_status'] == '1'){?>
<span class="w3-border w3-border-green w3-hover-border-black w3-white w3-padding-small"><i class="fa fa-check w3-text-green w3-hover-text-black"></i></span>
<?php }else{?>
<span class="w3-border w3-border-red w3-hover-border-black w3-white w3-padding-small"><i class="fa fa-minus-circle w3-text-red w3-hover-text-black"></i></span>
<?php }?>
</a></span>
</div>

</div>
<?php
  }
}
}?>
<div class="clearfix"></div><hr class="hr-trans mb-2 mt-1">
</div>
<?php }?>

Dodaj pliku językowego: catalog/includes/languages/polish/account.php

define('MY_ACCOUNT_PRODUCTS_REVIEWED', 'Produkty z ocenami');
define('MY_ACCOUNT_REVIEW_NOW_PRODUCTS', 'Jeszcze otwarte oceny');
define('MY_ACCOUNT_REVIEW_PRODUCTS_LG_MD', 'Oceń teraz');
define('MY_ACCOUNT_REVIEW_PRODUCTS_SM_XS', '');
define('MY_ACCOUNT_REVIEW_PRODUCTS_TODAY_NO_AVALIABLE_HEADER_INFO', 'Wszystkie z <span class="w3-border w3-border-red w3-white w3-padding-small"><i class="fa fa-minus-circle w3-text-red"></i></span > oznaczone produkty nie są dzisiaj dostępne.');
define('MY_ACCOUNT_REVIEW_NO_PRODUCTS_FOR_REVIEW', 'Nie kupiłeś jeszcze żadnych produktów, które mógłbyś ocenić.');

Zbudowany dla w3c-Commerce.
W przypadku innych wersji dostosuj formatowanie DIV CSS.


Informacja(1)
Informacje ogólne
 Lazy Loading
Licznik postów
Aktualny stan informacji:
Kategorie: 8
Posty: 104
Strony wsparcia: 51
Pobieranie dla członków: 104
Licznik pobierania: 646