{"id":376,"date":"2019-06-29T02:44:57","date_gmt":"2019-06-29T02:44:57","guid":{"rendered":"https:\/\/gpsites.co\/niche\/?p=376"},"modified":"2019-06-29T02:44:57","modified_gmt":"2019-06-29T02:44:57","slug":"the-single-product","status":"publish","type":"post","link":"https:\/\/new.acmestones.com\/index.php\/2019\/06\/29\/the-single-product\/","title":{"rendered":"The Single Product"},"content":{"rendered":"\n<p>Niche brings a new layout to the Single Product by introducing a stacked gallery for desktop, moves the Woocommerce breadcrumb and makes the summary Sticky. To do this required, guess what some Hook Elements and some CSS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Breadcrumb<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">#Hook 1 &#8211; Woo Breadcrumb Single product<\/h3>\n\n\n\n<p>Like the Shop page we are manually adding our breadcrumb. It&#8217;s hooked into the <code>woocommerce_single_product summary<\/code> and positioned at the top by setting the priority to 0 (zero).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php woocommerce_breadcrumb(); ?&gt;<\/code><\/pre>\n\n\n\n<p>Then a little font styling for the breadcrumb and product meta and creating a bit of space:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.product_meta&gt;span,\n.woocommerce-breadcrumb {\n    text-transform: uppercase;\n    font-size: 12px !important;\n    font-weight: 500;\n}\n\n.woocommerce div.product div.summary .woocommerce-breadcrumb {\n    margin-bottom: 40px;\n}<\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Gallery Stack and Sticky Summary<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">#Hook 2 &#8211;  Gallery Stack<\/h3>\n\n\n\n<p>Our first hook does all of the heavy lifting. Let&#8217;s take a look at the code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"woo-sumamry-wrap\"&gt;&lt;!-- open wrap --&gt;\n&lt;div class=\"woo-gallery-stack hide-on-mobile\"&gt;\n&lt;?php if ( has_post_thumbnail( $product-&gt;id ) ) {\n    $attachment_ids&#91;0] = get_post_thumbnail_id( $product-&gt;id );\n    $attachment = wp_get_attachment_image_src($attachment_ids&#91;0], 'full' ); ?&gt;    \n    &lt;img src=\"&lt;?php echo $attachment&#91;0] ; ?&gt;\"\/&gt;\n&lt;?php }\t\n\nglobal $product;\n$product_image_ids = $product-&gt;get_gallery_image_ids();\n\nforeach( $product_image_ids as $product_image_id ) {\n    $image_url = wp_get_attachment_url( $product_image_id );\n    echo '&lt;img src=\"'.$image_url.'\"&gt;';\n}?&gt;\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">First we create the Wrap<\/h4>\n\n\n\n<p>The first line of code <code>&lt;div class=\"woo-summary-wrap\"&gt;&lt;!-- open wrap --&gt;<\/code> opens a wrap around the gallery, summary and tabs. This is what constrains the sticky summary from overlapping with our full width related products.<\/p>\n\n\n\n<p>The code savy will notice our <code>woo-summary-wrap<\/code> doesn&#8217;t actually close off ie. no <code>&lt;\/div&gt;<\/code>. But don&#8217;t be alarmed, everything is ok.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Then we create the Stack<\/h4>\n\n\n\n<p>The rest of the code checks to see if thumbnails exists and then outputs the main featured image followed by a loop containing the other product images.  <\/p>\n\n\n\n<p>The gallery stack uses the full size image. It is advisable to upload images to suit this size. In the current setup we have a container width of 1320px. The gallery occupies around 60% of that width. This means the optimum full size image is around 800px wide.<\/p>\n\n\n\n<p>As these are the exact same images as used in the Gallery Carousel ( Magnification ) there is no double loading of images.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">#Hook 3 &#8211; Close Summary Wrap<\/h3>\n\n\n\n<p>Well it&#8217;s all in the title and finished off the piece of code in our first hook.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;\/div&gt;\n&lt;!-- Close gallery wrap --&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">CSS Styling to hide elements and make bits sticky<\/h3>\n\n\n\n<p>So the following CSS does several things:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Hide the default Woocommerce Gallery Carousel on Desktop.<\/li><li>Creates a 2 column grid to separate our images and our summary.<\/li><li>Adds some space (  bottom margin ) between our images.<\/li><li>Positions our summary and makes it sticky.<\/li><li>Repositions the Sale sticker over the image.<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>@media (min-width: 768px) {\n    .woocommerce-product-gallery {\n        display: none;\n    }\n\n    .woo-sumamry-wrap {\n        display: grid;\n        grid-template-columns: 60% 40%;\n        grid-template-rows: auto;\n        margin-bottom: 80px;\n    }\n\n    .woo-gallery-stack {\n        grid-column: 1;\n        grid-row: 1 \/ 3;\n    }\n\n    .woo-gallery-stack img {\n        margin-bottom: 20px;\n    }\n\n    .woocommerce-tabs {\n        grid-column: 1;\n    }\n\n    .woocommerce div.product div.summary {\n        grid-column: 2;\n        grid-row: 1;\n        margin-left: 80px;\n        position: -webkit-sticky;\n        position: sticky;\n        top: 105px;\n        bottom: 100px;\n        padding-right: 80px;\n    }\n\n    .single-product span.onsale {\n        position: absolute;\n        top: 0;\n    }\n}<\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">General Styling<\/h2>\n\n\n\n<p>Just a little adjustment to the top margin on the pricing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.woocommerce div.product p.price,\n.woocommerce div.product span.price,\n.woocommerce div.product p.price ins {\n    margin-top: 10px;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Niche brings a new layout to the Single Product by introducing a stacked gallery for desktop, moves the Woocommerce breadcrumb and makes the summary Sticky. To do this required, guess what some Hook Elements and &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"The Single Product\" class=\"read-more button\" href=\"https:\/\/new.acmestones.com\/index.php\/2019\/06\/29\/the-single-product\/#more-376\" aria-label=\"Read more about The Single Product\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-376","post","type-post","status-publish","format-standard","hentry","category-uncategorized","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"_links":{"self":[{"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/posts\/376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/comments?post=376"}],"version-history":[{"count":0,"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/posts\/376\/revisions"}],"wp:attachment":[{"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/media?parent=376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/categories?post=376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/new.acmestones.com\/index.php\/wp-json\/wp\/v2\/tags?post=376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}