Woocommerce cart layout

Hi there, I have a multilingual site and I am managing multilingual Woocommerce part of the site with a simple plugin (WooCommerce Polylang Integration).

I have customized some page layout with a x-theme function. including product pages and shop page and all works well. I have customized layout for italian language referring directly the page id. But I would like to change the layout of cart of every language using only one function.

I don’t know if exist a x-theme function for this. I have tried with x_is_cart and x_is_product_cart but non of these works.

This is the code I’m using:

function x_get_content_layout() {

  $content_layout = x_get_option( 'x_layout_content' );

  if ( $content_layout != 'full-width' ) {
    if ( is_home() ) {
      $opt    = x_get_option( 'x_blog_layout' );
      $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
    } elseif ( is_singular( 'post' ) ) {
      $meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
      $layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;
    } elseif ( x_is_portfolio_item() ) {
      $layout = 'full-width';
    } elseif ( x_is_portfolio() ) {
      $meta   = get_post_meta( get_the_ID(), '_x_portfolio_layout', true );
      $layout = ( $meta == 'sidebar' ) ? $content_layout : $meta;
    } elseif ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
      $layout = 'content-sidebar';
    } elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
      $layout = 'sidebar-content';
    } elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
      $layout = 'full-width';
    } elseif ( is_page('245')) {
      $layout = 'full-width';
    } elseif ( is_page('246')) {
      $layout = 'full-width';
    } elseif ( is_archive() ) {
      if ( x_is_cart() || x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
        $opt    = x_get_option( 'x_woocommerce_shop_layout_content' );
        $layout = 'full-width';
      } else {
        $opt    = x_get_option( 'x_archive_layout' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      }
    } elseif ( x_is_product() ) {
      $layout = 'full-width';
    } elseif ( x_is_bbpress() ) {
      $opt    = x_get_option( 'x_bbpress_layout_content' );
      $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
    } elseif ( x_is_buddypress() ) {
      $opt    = x_get_option( 'x_buddypress_layout_content' );
      $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
    } elseif ( is_404() ) {
      $layout = 'full-width';
    } else {
      $layout = $content_layout;
    }
  } else {
    $layout = $content_layout;
  }

  return $layout;

}

I hope you can help me, thank you very much

Hello Alessandro,

Thanks for writing in!

You should be using is_cart() function to find out if you are on the cart page or not. For more of the WooCommerce conditions, you can find it here:

Hope this helps.

Ok thank you! I was trying is_cart with x_ before…and I was convinced that it was right! With is_cart clearly it’s working.

Thank you very much

You’re welcome. Glad we’re able to lead you to the right direction.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.