<?php
get_header();
$is_cart_page = is_page('carrito');
if (function_exists('wc_get_page_id')) {
  $cart_page_id = wc_get_page_id('cart');
  if ($cart_page_id > 0 && is_page($cart_page_id)) {
    $is_cart_page = true;
  }
}
$is_account_page = function_exists('is_account_page') && is_account_page();
$is_checkout_page = function_exists('is_checkout') && is_checkout();
if ($is_cart_page) {
  echo '<main class="fjord-main">';
  if (function_exists('wc_load_cart')) {
    wc_load_cart();
  }
  $cart_template = get_stylesheet_directory() . '/woocommerce/cart/cart.php';
  if (file_exists($cart_template)) {
    include $cart_template;
  } else {
    echo do_shortcode('[woocommerce_cart]');
  }
  echo '</main>';
  get_footer();
  return;
}

if ($is_account_page || $is_checkout_page) {
  echo '<main class="fjord-main">';
  while (have_posts()) {
    the_post();
    the_content();
  }
  echo '</main>';
  get_footer();
  return;
}
?>

<main class="fjord-main fjord-page-split">
  <?php while (have_posts()) : the_post(); ?>
    <section class="fjord-page-split__layout">
      <aside class="fjord-page-split__media">
        <div class="fjord-page-split__media-inner">
          <?php if (has_post_thumbnail()) : ?>
            <?php the_post_thumbnail('large'); ?>
          <?php else : ?>
            <div class="fjord-page-split__placeholder"></div>
          <?php endif; ?>
        </div>
      </aside>
      <div class="fjord-page-split__content">
        <article class="fjord-page-split__card">
          <nav class="fjord-blog-post__breadcrumb" aria-label="Breadcrumb">
            <a href="<?php echo esc_url(home_url('/')); ?>">Home</a>
            <span class="fjord-blog-post__breadcrumb-sep">/</span>
            <span><?php the_title(); ?></span>
          </nav>
          <h1><?php the_title(); ?></h1>
          <div class="fjord-page-split__body">
            <?php the_content(); ?>
          </div>
        </article>
      </div>
    </section>
  <?php endwhile; ?>
</main>

<?php get_footer(); ?>
