Commit cb2d2518 authored by Quan Nguyen's avatar Quan Nguyen

update 19/10

parent 85565d2f
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
* @package WordPress * @package WordPress
*/ */
// ** URL setting ** // // ** URL setting ** //
define( 'WP_HOME', 'https://rangrangcoffee.com ); define( 'WP_HOME', 'https://rangrangcoffee.com' );
define( 'WP_SITEURL', 'https://coffee-shop.dev' ); define( 'WP_SITEURL', 'https://rangrangcoffee.com' );
// ** MySQL settings - You can get this info from your web host ** // // ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */ /** The name of the database for WordPress */
......
This diff is collapsed.
...@@ -71,85 +71,92 @@ class RRCKiotvietWcProduct ...@@ -71,85 +71,92 @@ class RRCKiotvietWcProduct
// Get product ID from SKU if created during the importation. // Get product ID from SKU if created during the importation.
if (empty($data['id']) && !empty($data['sku'])) { if (empty($data['id']) && !empty($data['sku'])) {
$product_id = wc_get_product_id_by_sku($data['sku']); $product_id = wc_get_product_id_by_sku($data['sku']);
$id1 = "ID: " . $product_id;
$this->check_update_product_by_config($data); $this->check_update_product_by_config($data);
if ($product_id) { if ($product_id) {
$data['id'] = $product_id; $data['id'] = $product_id;
} }
} }
$object = $this->get_product_object($data);
if ($object->get_status() == "trash") { $id1 = empty($data['id']) . " and " . !empty($data['sku']) . " and " . $data['simple'];
$data['status'] = "trash";
}
if (is_wp_error($object)) { // return (empty($data['id']) && !empty($data['sku']));
return $object; return $id1;
}
if ('external' === $object->get_type()) { // $object = $this->get_product_object($data);
unset($data['manage_stock'], $data['stock_status'], $data['backorders'], $data['low_stock_amount']);
}
if ('variation' === $object->get_type()) { // if ($object->get_status() == "trash") {
if (isset($data['status']) && -1 === $data['status']) { // $data['status'] = "trash";
$data['status'] = 0; // Variations cannot be drafts - set to private. // }
}
}
if ('importing' === $object->get_status()) { // if (is_wp_error($object)) {
$object->set_status('publish'); // return $object;
$object->set_slug(''); // }
}
$result = $object->set_props(array_diff_key($data, array_flip(array('meta_data', 'raw_image_id', 'raw_gallery_image_ids', 'raw_attributes')))); // if ('external' === $object->get_type()) {
// unset($data['manage_stock'], $data['stock_status'], $data['backorders'], $data['low_stock_amount']);
// }
if (is_wp_error($result)) { // if ('variation' === $object->get_type()) {
throw new Exception($result->get_error_message()); // if (isset($data['status']) && -1 === $data['status']) {
} // $data['status'] = 0; // Variations cannot be drafts - set to private.
// }
// }
if ('variation' === $object->get_type()) { // if ('importing' === $object->get_status()) {
$this->set_variation_data($object, $data); // $object->set_status('publish');
} else { // $object->set_slug('');
$this->set_product_data($object, $data); // }
}
$this->set_image_data($object, $data); // $result = $object->set_props(array_diff_key($data, array_flip(array('meta_data', 'raw_image_id', 'raw_gallery_image_ids', 'raw_attributes'))));
$this->set_meta_data($object, $data); // if (is_wp_error($result)) {
// throw new Exception($result->get_error_message());
// }
$object = apply_filters('woocommerce_product_import_pre_insert_product_object', $object, $data); // if ('variation' === $object->get_type()) {
// $this->set_variation_data($object, $data);
// } else {
// $this->set_product_data($object, $data);
// }
$object->save(); // $this->set_image_data($object, $data);
// $this->set_meta_data($object, $data);
// $object = apply_filters('woocommerce_product_import_pre_insert_product_object', $object, $data);
//Store stock location // $object->save();
if($data['manage_stock'] == 1) {
$this->set_stock_location_data($data, $object->get_id());
} else {
update_post_meta($object->get_id(), "_stock_status", "instock");
}
if ($data['kvProductType'] == "thue-bao"){
//enable sub
//enable gift
//set min/max ship // //Store stock location
// if($data['manage_stock'] == 1) {
// $this->set_stock_location_data($data, $object->get_id());
// } else {
// update_post_meta($object->get_id(), "_stock_status", "instock");
// }
//set frequency // if ($data['kvProductType'] == "thue-bao"){
// //enable sub
//set image // //enable gift
//create variation // //set min/max ship
$this->create_variation_product($object, $data);
} // //set frequency
// change status when update product trash // //set image
do_action('woocommerce_product_import_inserted_product_object', $object, $data);
return $object->get_id(); // //create variation
// $this->create_variation_product($object, $data);
// }
// // change status when update product trash
// do_action('woocommerce_product_import_inserted_product_object', $object, $data);
// return $object->get_id();
} catch (Exception $e) { } catch (Exception $e) {
return new WP_Error('woocommerce_product_importer_error', $e->getMessage(), array('status' => $e->getCode())); return new WP_Error('woocommerce_product_importer_error', $e->getMessage(), array('status' => $e->getCode()));
} }
...@@ -1131,18 +1138,18 @@ class RRCKiotvietWcProduct ...@@ -1131,18 +1138,18 @@ class RRCKiotvietWcProduct
public function productSimple($product) public function productSimple($product)
{ {
$productSimple = $this->import_product($product); $productSimple = $product;//$this->import_product($product);
if (!is_wp_error($productSimple)) { // if (!is_wp_error($productSimple)) {
$this->insertProductMap([ // $this->insertProductMap([
'product_id' => $productSimple, // 'product_id' => $productSimple,
'product_kv_id' => $product['kv_id'], // 'product_kv_id' => $product['kv_id'],
'data_raw' => json_encode($product, JSON_UNESCAPED_UNICODE), // 'data_raw' => json_encode($product, JSON_UNESCAPED_UNICODE),
'parent' => 0, // 'parent' => 0,
'retailer' => $this->retailer, // 'retailer' => $this->retailer,
'created_at' => rrc_kiotviet_sync_get_current_time(), // 'created_at' => rrc_kiotviet_sync_get_current_time(),
'status' => 1 // 'status' => 1
]); // ]);
} // }
return $productSimple; return $productSimple;
} }
......
...@@ -272,7 +272,6 @@ class Rrc_Kiotviet_Sync_Service_Product ...@@ -272,7 +272,6 @@ class Rrc_Kiotviet_Sync_Service_Product
foreach ($products as $product) { foreach ($products as $product) {
$data = [ $data = [
'id' => '',
'kv_id' => $product->id, 'kv_id' => $product->id,
'retailerId' => $product->retailerId, 'retailerId' => $product->retailerId,
'code' => $product->code, 'code' => $product->code,
...@@ -318,7 +317,6 @@ class Rrc_Kiotviet_Sync_Service_Product ...@@ -318,7 +317,6 @@ class Rrc_Kiotviet_Sync_Service_Product
$data['category_ids'] = array(!empty($categorySync[$data['category_kv']]) ? $categorySync[$data['category_kv']] : []); $data['category_ids'] = array(!empty($categorySync[$data['category_kv']]) ? $categorySync[$data['category_kv']] : []);
if ($updateProduct) { if ($updateProduct) {
$data['id'] = $productSync[$data['kv_id']]->product_id;
$id = $this->update($data); $id = $this->update($data);
array_push($result, $id); array_push($result, $id);
} else { } else {
...@@ -385,36 +383,38 @@ class Rrc_Kiotviet_Sync_Service_Product ...@@ -385,36 +383,38 @@ class Rrc_Kiotviet_Sync_Service_Product
public function update($products) public function update($products)
{ {
//set stock config
if($product['kvProductType'] == "thue-bao" || $product['kvProductType'] == "che-bien" || $product['kvProductType'] == "combo" || $product['kvProductType'] == "dich-vu") {
$product['manage_stock'] = 0;
} else if($product['kvProductType'] == "thong-thuong") {
$product['manage_stock'] = 1;
$product['low_stock_amount'] = 0;
$product['parent_id'] = 0;
}
//map product type in kiotviet and wc //map product type in kiotviet and wc
if ($product['hasVariants'] == true) { if ($product['hasVariants'] == true) {
if ($product['kvProductType'] == "thue-bao"){ if ($product['kvProductType'] == "thue-bao"){
if($product['masterProductId'] != null ){ $product['type'] = "variable";
$product['parent_id'] = $this->getProductParent($product['masterProductId']); $result = $this->KiotvietWcProduct->productVariable($product);
}
} else { } else {
$product['type'] = "simple";
if (isset($product['unit']) && !empty($product['unit'])) { if (isset($product['unit']) && !empty($product['unit'])) {
$product['name'] = $product['name'] . " - " . $product['unit']; $product['name'] = $product['name'] . " - " . $product['unit'];
} }
$result = $this->KiotvietWcProduct->productSimple($product);
} }
} else { } else {
$product['type'] = "simple";
if (isset($product['unit']) && !empty($product['unit'])) { if (isset($product['unit']) && !empty($product['unit'])) {
$product['name'] = $product['name'] . " - " . $product['unit']; $product['name'] = $product['name'] . " - " . $product['unit'];
} }
}
//set stock config $result = $this->KiotvietWcProduct->productSimple($product);
if($product['kvProductType'] == "thue-bao" || $product['kvProductType'] == "che-bien" || $product['kvProductType'] == "combo" || $product['kvProductType'] == "dich-vu") {
$product['manage_stock'] = 0;
} else if($product['kvProductType'] == "thong-thuong") {
$product['manage_stock'] = 1;
$product['low_stock_amount'] = 0;
$product['parent_id'] = 0;
} }
//check meta data, location, product type //check meta data, location, product type
$result = $this->KiotvietWcProduct->productSimple($product);
return $result; return $result;
} }
......
...@@ -4362,24 +4362,75 @@ div.filter::-webkit-scrollbar { ...@@ -4362,24 +4362,75 @@ div.filter::-webkit-scrollbar {
} }
/*-------- 2.27 Same product --------*/ /*-------- 2.27 Same product --------*/
.same-product { .same-product .section-title-20 {
color: #555555; padding-bottom: 15px;
margin-bottom: 40px;
border-bottom: 1px solid #D1CFCF;
} }
.same-product .card { .same-product .card {
border-radius: 0; border-radius: 0;
border: none; border: none;
box-shadow: #0000000d 0px 6px 24px 0px, #802d2d08 0px 0px 0px 1px; box-shadow: none;
}
.same-product .card:hover {
box-shadow: 0 12px 30px 0 #f5f5f7;
} }
.same-product .card:hover .card-img-top { .same-product .card:hover .card-img-top {
transform: scale(1.1) !important; transform: scale(1.1) !important;
} }
.same-product .card .card-body {
position: relative;
padding: 0;
}
.same-product .card .card-body__left {
flex: 1;
}
.same-product .card .card-body__left-title {
color: #141414;
}
.same-product .card .card-body__left-title h5 {
margin-top: 12px;
}
.same-product .card .card-body__left p {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
height: 40px;
}
@media (max-width: 991px) {
.same-product .card .card-body__left p {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
height: 60px;
}
}
.same-product .card .card-body__right p.border-text {
border-bottom: 1.5px solid #444444;
font-size: 12px;
}
.same-product .card .card-body__right p {
padding-top: 12px;
padding-bottom: 4px;
}
@media (max-width: 991px) {
.same-product .card .card-body__right p {
margin-bottom: 0;
}
}
.same-product .card .same-product__image-container { .same-product .card .same-product__image-container {
overflow: hidden; overflow: hidden;
} }
...@@ -4402,7 +4453,7 @@ div.filter::-webkit-scrollbar { ...@@ -4402,7 +4453,7 @@ div.filter::-webkit-scrollbar {
@media (min-width: 992px) { @media (min-width: 992px) {
.same-product .card .same-product__image-container { .same-product .card .same-product__image-container {
height: 225px; height: 200px;
} }
} }
...@@ -4710,7 +4761,11 @@ div.filter::-webkit-scrollbar { ...@@ -4710,7 +4761,11 @@ div.filter::-webkit-scrollbar {
.subs__item-img { .subs__item-img {
margin-top: 24px; margin-top: 24px;
margin-bottom: 8px; margin-bottom: 8px;
width: 100%; max-width: 100%;
}
.subs__item-img.icon {
width: 100px;
} }
.subs__conatiner--popular { .subs__conatiner--popular {
......
...@@ -201,7 +201,10 @@ function subscription_re_order( $order_id, $num_ship ) { ...@@ -201,7 +201,10 @@ function subscription_re_order( $order_id, $num_ship ) {
return; return;
} }
// do something // send mail expired order
if ( $cron_count != 0 && (int) $cron_count == ($num_ship - 1) ) {
}
//update num ship //update num ship
......
<?php
/**
* Template Name: Category Template
*
* Template for displaying Coffee subscriptions content
*
* @package Rang_Rang_Coffee
*/
get_header();
$category_slug_params = "";
$product_name_params = "";
if (isset($_GET['type'])) {
$category_slug_params = $_GET['type'];
}
if (isset($_GET['search'])) {
$product_name_params = $_GET['search'];
}
?>
<main>
<?php
$args = array();
$argsProduct = array();
if (isset($_GET['type'])) {
$argsProduct = array(
'category' => array($category_slug_params),
);
} else {
if (isset($_GET['search'])) {
$argsProduct = array(
'like_name' => $product_name_params,
);
} else {
$argsProduct = array(
'posts_per_page' => 10,
);
}
}
$loop = new WP_Query($args);
$products = wc_get_products($argsProduct);
function filter_product_type($product_id, $processing_type_slug)
{
$processing_type = wp_get_object_terms($product_id, $processing_type_slug);
$data_filter = "";
if (!is_wp_error($processing_type) && count($processing_type) > 0) {
for ($j = 0; $j < count($processing_type); $j++) {
if ($j != count($processing_type) - 1) {
$data_filter .= $processing_type[$j]->slug . ',';
} else {
$data_filter .= $processing_type[$j]->slug;
}
}
}
return $data_filter;
}
function render_product_item($product_item, $allType, $class_item = "")
{
?>
<div class="col-md-6 col-12 <?php echo $class_item ?>" data-filter-all='<?php echo $allType ?>'>
<div class="card w-100 d-flex flex-row flex-md-column mb-4">
<div class="product__image-container">
<a href="<?php echo get_permalink($product_item->get_id()) ?>">
<?php
if (get_post_thumbnail_id($product_item->get_id())) {
$image = wp_get_attachment_image_src(get_post_thumbnail_id($product_item->get_id()), 'single-post-thumbnail');
echo "<img src='$image[0]' alt='product' class='card-img-top'>";
} else {
$image = wc_placeholder_img_src();
echo '<img src="' . esc_url($image) . '" ' . ' class="card-img-top"/>';
}
?>
</a>
</div>
<div class="card-body d-flex flex-row">
<a href="<?php echo get_permalink($product_item->get_id()) ?>" class="d-block d-lg-flex w-100">
<div class="card-body__left">
<h5 class="f16 font-weight-bold"><?php echo $product_item->get_title(); ?></h5>
<p class="f14 font-italic">
<?php
$excerptText = $product_item->get_short_description();
echo $excerptText;
?>
</p>
</div>
<div class="card-body__right">
<p class="f14 border-text text-uppercase d-lg-block d-inline ml-0 ml-lg-2">
SHOP NOW
</p>
</div>
</a>
</div>
</div>
</div>
<?php
}
$category = get_term_by('slug', $category_slug_params, 'product_cat');
?>
<section class="hero hero-small">
<div class="hero__banner">
<?php
$cover_cat = get_field('image', 'product_cat_' . $category->term_id);
$size = 'full';
if ($cover_cat) { ?>
<img src="<?php echo $cover_cat['url'] ?>" />
<?php
} else { ?>
<img class="mb-3" src="<?php echo get_theme_file_uri('assets/img/RR-default-bg-image.jpg') ?>" alt="logo">
<?php
}
?>
</div>
</section>
<section class="product-categories">
<div class="container">
<div class="section-title-20">
<?php
echo $category->name;
?>
</div>
<div class="product product-preview mt-4">
<div class="row">
<?php
$current_page = 0;
$MAX_PER_PAGE = 10;
$url = strtok($_SERVER["REQUEST_URI"], '?');
$url_page_item = $url . "?page-store=";
if ($category_slug_params != "") {
$url = strtok($_SERVER["REQUEST_URI"], '?') . "?type=" . $category_slug_params . "&";
$url_page_item = $url . "&page-store=";
}
if (isset($_GET['page-store'])) {
$current_page = intval($_GET['page-store']) - 1;
}
for ($i = 0; $i < count($products); $i++) {
?>
<?php
$data_filter_cf = filter_product_type($products[$i]->get_id(), 'coffee_type');
$data_filter_processing = filter_product_type($products[$i]->get_id(), 'processing');
$data_filter_region = filter_product_type($products[$i]->get_id(), 'region');
$data_filter_product_type = filter_product_type($products[$i]->get_id(), 'kv_product_type');
$allType = $data_filter_cf . "|" . $data_filter_processing . "|" . $data_filter_region . "|" . $data_filter_product_type;
if ($i >= $current_page * $MAX_PER_PAGE & $i < $current_page * $MAX_PER_PAGE + $MAX_PER_PAGE & $i < count($products)) {
render_product_item($products[$i], $allType, 'current-page');
} else {
render_product_item($products[$i], $allType, 'd-none');
}
}
?>
<?php
wp_reset_query();
?>
</div>
<?php
function render_paginiation_item($first, $last, $condition, $current_page)
{
global $url_page_item;
if ($first < 1) {
$first = 1;
}
for ($i = $first; $i <= $condition && $i < $last; $i++) {
if ($current_page == $i - 1) {
echo "<li class='page-item '><a class='page-link active' href='$url_page_item$i '> $i </a></li>";
} else {
echo "<li class='page-item'><a class='page-link' href='$url_page_item$i '> $i </a></li>";
}
}
}
if (count($products) > $MAX_PER_PAGE) {
?>
<ul class="pagination pagination-custom justify-content-end mb-5 mt-4">
<?php
$page_last = ceil(count($products) / $MAX_PER_PAGE);
$so_on_product = "<li class='page-item'><div class='page-link' > ... </div></li>";
if ($current_page == 0) {
render_paginiation_item(1, $page_last + 1, $current_page + 3, $current_page);
if ($page_last > 3) {
echo $so_on_product;
}
?>
<li class='page-item'><a class='page-link' href=' <?php echo $url_page_item . $page_last ?>'><?php pll_e('Last') ?> </a>
</li>
<?php
} else if ($current_page * $MAX_PER_PAGE + $MAX_PER_PAGE >= count($products)) {
?>
<li class='page-item'><a class='page-link' href='<?php echo $url ?>'><?php pll_e('First') ?></a></li>
<?php
if ($page_last > 3) {
echo $so_on_product;
}
render_paginiation_item($current_page - 1, $page_last + 1, $current_page + 1, $current_page);
} else {
?>
<li class='page-item'><a class='page-link' href='<?php echo $url ?>'> <?php pll_e('First') ?> </a></li>
<?php
if ($page_last > 3 && $current_page - 2 >= 0) {
echo $so_on_product;
}
render_paginiation_item($current_page, $page_last + 1, $current_page + $MAX_PER_PAGE, $current_page);
if ($page_last > 3 && $current_page + 2 < $page_last) {
echo $so_on_product;
}
?>
<li class='page-item'><a class='page-link' href='<?php echo $url_page_item . $page_last ?>'><?php pll_e('Last') ?></a>
</li>
<?php }
?>
</ul>
<?php
}
?>
</div>
</div>
</section>
<div class="container">
<div class="product-notfound product-filter text-center pv-40 d-none">
<img src="<?php echo get_theme_mod('notfound_image'); ?>" alt="notfound">
<h5 class="section-title-20">
<?php pll_e("We couldn't find any coffees that matched your applied filters.") ?>
</h5>
<div class="btn"><?php pll_e('Clear all filter') ?></div>
</div>
<?php if (is_active_sidebar('coffee-subscription-section')) : ?>
<?php dynamic_sidebar('coffee-subscription-section'); ?>
<?php endif; ?>
</main>
<?php
get_footer();
?>
\ No newline at end of file
...@@ -124,7 +124,6 @@ if (isset($_GET['search'])) { ...@@ -124,7 +124,6 @@ if (isset($_GET['search'])) {
} }
$list_provice_address = array_count_values($list_address_arr); $list_provice_address = array_count_values($list_address_arr);
?> ?>
</form>
<?php <?php
...@@ -298,15 +297,12 @@ if (isset($_GET['search'])) { ...@@ -298,15 +297,12 @@ if (isset($_GET['search'])) {
'parent' => 0, 'parent' => 0,
); );
$product_categories = get_terms('product_cat', $cat_args); $product_categories = get_terms('product_cat', $cat_args);
$current_url = "";
if (get_locale() != "en_US") {
$current_url = "/" . get_locale();
}
foreach ($product_categories as $key => $category) { foreach ($product_categories as $key => $category) {
?> ?>
<div class="col-md-4 col-6 text-center"> <div class="col-md-4 col-6 text-center">
<a href="<?php echo $current_url . '/category?type=' . $category->slug ?>" class="list-product-item d-inline-block"> <a href="<?php echo get_category_link($category->term_id) ?>" class="list-product-item d-inline-block">
<div class="list-product-item__wrap"> <div class="list-product-item__wrap">
<?php <?php
$thumbnail_id = get_term_meta($category->term_id, 'thumbnail_id', true); $thumbnail_id = get_term_meta($category->term_id, 'thumbnail_id', true);
......
...@@ -6,60 +6,56 @@ ...@@ -6,60 +6,56 @@
* @version 3.6.0 * @version 3.6.0
*/ */
defined( 'ABSPATH' ) || exit; defined('ABSPATH') || exit;
global $product; global $product;
// Ensure visibility. // Ensure visibility.
if ( empty( $product ) || ! $product->is_visible() ) { if (empty($product) || !$product->is_visible()) {
return; return;
} }
$coffee_types = get_the_terms( $product->get_id(), 'coffee_type' );
if ( ! empty( $coffee_types ) ) {
$coffee_type = $coffee_types[0];
}
$product_img = get_the_post_thumbnail_url( $product->get_id() );
$product_img = get_the_post_thumbnail_url($product->get_id());
$product_img = $product_img == false ? wc_placeholder_img_src() : $product_img; $product_img = $product_img == false ? wc_placeholder_img_src() : $product_img;
$desc = esc_html( $product->get_short_description() ); $desc = esc_html($product->get_short_description());
$price = $product->get_price(); $price = $product->get_price();
?> ?>
<div <?php wc_product_class( 'col-12 col-md-6 col-lg-3 mb-3', $product ); ?>> <div class="col-12 col-md-6 col-lg-3 mb-3">
<div class="card w-100 h-100 h-md-auto d-flex d-md-block flex-row flex-md-column mb-4 mb-lg-0"> <div class="card w-100 h-100 h-md-auto d-flex d-md-block flex-row flex-md-column mb-4 mb-lg-0">
<div class="same-product__image-container"> <div class="same-product__image-container">
<a href="<?php echo get_permalink( $product->get_id() ); ?>"> <a href="<?php echo get_permalink($product->get_id()); ?>">
<img src="<?php echo $product_img; ?>" class="card-img-top" alt="<?php echo $product->get_name(); ?> image"> <img src="<?php echo $product_img; ?>" class="card-img-top" alt="<?php echo $product->get_name(); ?> image">
</a> </a>
</div> </div>
<div class="card-body p-2"> <div class="card-body p-3 p-md-0">
<?php if ( isset( $coffee_type ) ) { ?> <div class="d-block d-lg-flex w-100">
<a href="<?php printf( '/%s/%s', $coffee_type->taxonomy, $coffee_type->slug ); ?>"> <div class="card-body__left">
<span class="same-product__tag"> <a class="card-body__left-title d-block" href="<?php echo get_permalink($product->get_id()); ?>">
<?php echo esc_html( $coffee_type->name ); ?> <h5 class="f16 font-weight-bold"><?php echo $product->get_name(); ?></h5>
</span>
</a> </a>
<?php } ?> <p class="f14 font-italic">
<?php if (!empty($desc)) {
<a class="card-title" href="<?php echo get_permalink( $product->get_id() ); ?>"> echo $desc;
<h5 class="f16 text-left text-md-center mt-2"> } ?>
<?php echo $product->get_name(); ?>
</h5>
</a>
<?php if ( ! empty( $desc ) ) { ?>
<p class="f14 font-italic description text-left text-md-center">
<?php echo $desc; ?>
</p> </p>
<?php } ?> </div>
<div class="card-body__right">
<?php if ( ! empty( $price ) ) { ?> <p class="
<p class="f14 text-left text-md-center"> f14
<?php echo wc_price( $price ); ?> border-text
text-uppercase
d-lg-block d-inline
ml-0 ml-lg-2
">
<?php pll_e('shop now') ?>
</p> </p>
<?php } ?> </div>
</div>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -11,18 +11,16 @@ if ( ! defined( 'ABSPATH' ) ) { ...@@ -11,18 +11,16 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
if ( $related_products ) : ?> if ( $related_products ) : ?>
<section class="container same-product related products mt-4"> <section class="container same-product mt-4">
<?php <?php
$heading = apply_filters( 'woocommerce_product_related_products_heading', pll__( 'You might also like' ) ); $heading = apply_filters( 'woocommerce_product_related_products_heading', pll__( 'Related products' ) );
if ( $heading ) : if ( $heading ) :
?> ?>
<h2 class="text-center section-title-24 mb-4 text-primary"> <div class="section-title-20"> <?php echo esc_html( $heading ); ?></div>
<?php echo esc_html( $heading ); ?>
</h2>
<?php endif; ?> <?php endif; ?>
<?php woocommerce_product_loop_start(); ?> <?php woocommerce_product_loop_start(); ?>
<div class="products row justify-content-center"> <div class="same-product row justify-content-center">
<?php foreach ( $related_products as $related_product ) : ?> <?php foreach ( $related_products as $related_product ) : ?>
<?php <?php
......
<?php
/**
*
* This template can be overridden by INVI dev
*
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce\Templates
* @version 3.4.0
*/
get_header();
// get categories
global $post;
$category = wp_get_post_terms($post->ID, 'product_cat');
?>
<main>
<?php
$products = wc_get_products(array(
'category' => array($category[0]->slug),
));
?>
<section class="hero hero-small">
<div class="hero__banner">
<?php
$cover_cat = get_field('image', 'product_cat_' . $category[0]->term_id);
$size = 'full';
if ($cover_cat) { ?>
<img src="<?php echo $cover_cat['url'] ?>" />
<?php
} else { ?>
<img class="mb-3" src="<?php echo get_theme_file_uri('assets/img/RR-default-bg-image.jpg') ?>" alt="logo">
<?php
}
?>
</div>
</section>
<section class="product-categories">
<div class="container">
<div class="section-title-20">
<?php
echo $category[0]->name;
?>
</div>
<div class="product product-preview mt-4">
<div class="row">
<?php
$current_page = 0;
$MAX_PER_PAGE = 4;
$url = strtok($_SERVER["REQUEST_URI"], '?');
$url_page_item = $url . "?page-store=";
if (isset($_GET['page-store'])) {
$current_page = intval($_GET['page-store']) - 1;
}
for ($i = 0; $i < count($products); $i++) {
if ($i >= $current_page * $MAX_PER_PAGE & $i < $current_page * $MAX_PER_PAGE + $MAX_PER_PAGE & $i < count($products)) {
?>
<div class="col-md-6 col-12">
<div class="card w-100 d-flex flex-row flex-md-column mb-4">
<div class="product__image-container">
<a href="<?php echo get_permalink($products[$i]->get_id()) ?>">
<?php
if (get_post_thumbnail_id($products[$i]->get_id())) {
$image = wp_get_attachment_image_src(get_post_thumbnail_id($products[$i]->get_id()), 'single-post-thumbnail');
echo "<img src='$image[0]' alt='product' class='card-img-top'>";
} else {
$image = wc_placeholder_img_src();
echo '<img src="' . esc_url($image) . '" ' . ' class="card-img-top"/>';
}
?>
</a>
</div>
<div class="card-body d-flex flex-row">
<a href="<?php echo get_permalink($products[$i]->get_id()) ?>" class="d-block d-lg-flex w-100">
<div class="card-body__left">
<h5 class="f16 font-weight-bold"><?php echo $products[$i]->get_title(); ?></h5>
<p class="f14 font-italic">
<?php
$excerptText = $products[$i]->get_short_description();
echo $excerptText;
?>
</p>
</div>
<div class="card-body__right">
<p class="f14 border-text text-uppercase d-lg-block d-inline ml-0 ml-lg-2">
<?php pll_e('shop now'); ?>
</p>
</div>
</a>
</div>
</div>
</div>
<?php
}
}
if (count($products) > $MAX_PER_PAGE) {
function render_paginiation_item($first, $last, $condition, $current_page)
{
global $url_page_item;
if ($first < 1) {
$first = 1;
}
for ($i = $first; $i <= $condition && $i < $last; $i++) {
if ($current_page == $i - 1) {
echo "<li class='page-item '><a class='page-link active' href='$url_page_item$i '> $i </a></li>";
} else {
echo "<li class='page-item'><a class='page-link' href='$url_page_item$i '> $i </a></li>";
}
}
}
?>
<div class="col-12 text-end">
<ul class="pagination pagination-custom justify-content-end mb-5 mt-4">
<?php
$page_last = ceil(count($products) / $MAX_PER_PAGE);
$so_on_product = "<li class='page-item'><div class='page-link' > ... </div></li>";
if ($current_page == 0) {
render_paginiation_item(1, $page_last + 1, $current_page + 3, $current_page);
if ($page_last > 3) {
echo $so_on_product;
}
?>
<li class='page-item'><a class='page-link' href=' <?php echo $url_page_item . $page_last ?>'><?php pll_e('Last') ?> </a>
</li>
<?php
} else if ($current_page * $MAX_PER_PAGE + $MAX_PER_PAGE >= count($products)) {
?>
<li class='page-item'><a class='page-link' href='<?php echo $url ?>'><?php pll_e('First') ?></a></li>
<?php
if ($page_last > 3) {
echo $so_on_product;
}
render_paginiation_item($current_page - 1, $page_last + 1, $current_page + 1, $current_page);
} else {
?>
<li class='page-item'><a class='page-link' href='<?php echo $url ?>'> <?php pll_e('First') ?> </a></li>
<?php
if ($page_last > 3 && $current_page - 2 >= 0) {
echo $so_on_product;
}
render_paginiation_item($current_page, $page_last + 1, $current_page + $MAX_PER_PAGE, $current_page);
if ($page_last > 3 && $current_page + 2 < $page_last) {
echo $so_on_product;
}
?>
<li class='page-item'><a class='page-link' href='<?php echo $url_page_item . $page_last ?>'><?php pll_e('Last') ?></a>
</li>
<?php }
?>
</ul>
</div>
<?php
}
?>
</div>
</div>
</div>
</section>
</main>
<?php
get_footer();
2021-10-19T03:42:33+00:00 ERROR Error getting remote inbox notification data feed
2021-10-19T03:42:33+00:00 ERROR WP_Error Object
(
[errors] => Array
(
[http_request_failed] => Array
(
[0] => cURL error 60: SSL certificate problem: certificate has expired
)
)
[error_data] => Array
(
)
[additional_data:protected] => Array
(
)
)
2021-10-19T03:43:29+00:00 ERROR Error getting remote inbox notification data feed
2021-10-19T03:43:29+00:00 ERROR WP_Error Object
(
[errors] => Array
(
[http_request_failed] => Array
(
[0] => cURL error 60: SSL certificate problem: certificate has expired
)
)
[error_data] => Array
(
)
[additional_data:protected] => Array
(
)
)
2021-10-19T08:38:36+00:00 ERROR Error getting remote inbox notification data feed
2021-10-19T08:38:36+00:00 ERROR WP_Error Object
(
[errors] => Array
(
[http_request_failed] => Array
(
[0] => cURL error 60: SSL certificate problem: certificate has expired
)
)
[error_data] => Array
(
)
[additional_data:protected] => Array
(
)
)
2021-10-19T08:38:36+00:00 ERROR Error getting remote inbox notification data feed
2021-10-19T08:38:36+00:00 ERROR WP_Error Object
(
[errors] => Array
(
[http_request_failed] => Array
(
[0] => cURL error 60: SSL certificate problem: certificate has expired
)
)
[error_data] => Array
(
)
[additional_data:protected] => Array
(
)
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment