Skip to content

Commit

Permalink
14.4.2
Browse files Browse the repository at this point in the history
- [WooCommerce] Better UX for different price in variation
  • Loading branch information
hrsetyono committed Nov 29, 2022
1 parent 4e6b2c0 commit d7b3d83
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 24 deletions.
2 changes: 1 addition & 1 deletion _dist/gutenberg.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'fa6e1d1e5512be89eb28ba3ae6262fbd');
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'e5ddf90008c3ddc77f07cc735d71f859');
2 changes: 1 addition & 1 deletion _dist/gutenberg.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _dist/shop.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'bd46e5b1cda8a6ce66ab214fa8094dab');
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '9370b812571a5ad128764160b8686409');
2 changes: 1 addition & 1 deletion _dist/shop.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _dist/shop.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/css/gutenberg/_core-media.sass
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
// Cover Below Header
.wp-block-cover.is-style-h-below-header
margin-top: calc(var(--headerHeight) * -1)
padding-top: calc(var(--headerHeight))

body.h-has-cover-below-header
.header:not(.is-stuck),
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Theme Name: Edje Boilerplate Theme
Author: Pixel Studio
Author URI: https://pixelstudio.id
Description: Boilerplate WordPress theme to be used alongside Edje WP Library
Version: 14.4.1
Version: 14.4.2
Tags: private theme, edje, acf, woocommerce, custom-menu, editor-style
*/

Expand Down
36 changes: 22 additions & 14 deletions woocommerce/css/_shop-single.sass
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.product-columns
align-items: flex-start
column-gap: 4rem

@media ($below-m)
Expand All @@ -7,7 +8,8 @@
///// GALLERY
.product-figure
position: relative
position: sticky
top: calc(var(--headerHeight) + var(--adminBarHeight))

div.woocommerce-product-gallery
margin-top: 0
Expand Down Expand Up @@ -85,23 +87,33 @@ div.woocommerce-product-gallery
.product-summary
h1
font-size: var(--h2Size)
font-size: var(--h3Size)

.price
display: flex
justify-content: flex-start
margin-top: var(--blockGap)
font-size: var(--h4Size)
font-size: var(--h3Size)
color: var(--text)

.stock
font-weight: 700
font-size: var(--mFontSize)
line-height: 1

del
font-size: var(--h5Size)


// Sold and Rating
.product-summary__subheader
display: flex
align-items: center
margin-top: 0

> *:nth-child(n+2)::before
content: ""
display: inline-block
padding: 0 0.75rem
color: var(--gray)

span
color: var(--gray)

form.cart
display: flex
Expand Down Expand Up @@ -216,7 +228,6 @@ table.variations

th,
td
padding-top: 0.5rem
padding-bottom: 0.5rem

// I don't see a use of this
Expand Down Expand Up @@ -259,16 +270,14 @@ a.reset_variations
margin-bottom: 0.5rem

.price
margin: 0
font-size: var(--mFontSize)
display: none !important // change the big price instead

.stock
padding: 0 0.5rem
border-radius: var(--gRadius)
margin-left: 1rem
background-color: rgba(--text, .2)
font-weight: var(--fontWeight)
font-size: var(--sFontSize)
font-size: var(--fontSize)

.out-of-stock
background-color: var(--colorAlertLight)
Expand All @@ -279,7 +288,6 @@ a.reset_variations
div.woocommerce-product-rating
display: flex
align-items: center
margin-top: 0.5rem

.woocommerce-review-link
margin-left: 0.5rem
Expand Down
4 changes: 4 additions & 0 deletions woocommerce/css/_shop-widgets.sass
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@
path
fill: var(--textInvert)

body.h-has-cover-below-header .header-widgets:not(.is-stuck) &
border-color: rgba(--textInvert, .3)
color: var(--textInvert)

&:hover
transform: translateY(-2px)
border-color: rgba(--text, .5)
Expand Down
19 changes: 18 additions & 1 deletion woocommerce/js/shop.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const myCart = {

function openBar(e) {
e.stopPropagation();
console.log('click bar');
const $form = e.currentTarget;

if (!$form.classList.contains('is-toggled')) {
Expand Down Expand Up @@ -74,9 +73,27 @@ const mySlider = {
},
};

const myVariation = {
init() {
const $form = document.querySelector('form.variations_form');

// Change the big price
if ($form) {
window.jQuery($form).on('found_variation', (e, variation) => {
const $price = document.querySelector('.product-summary .price');
const newPrice = variation.price_html
.replace(/^<span class="price">/g, '')
.replace(/<\/span>$/g, '');
$price.innerHTML = newPrice;
});
}
},
};

function onReady() {
myCart.init();
mySlider.init();
myVariation.init();
}

function onLoad() {
Expand Down
13 changes: 10 additions & 3 deletions woocommerce/views/single-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@
?>
</div>
<div class="product-summary / wp-block-column">
<?php // do_action('woocommerce_single_product_summary'); ?>
<?php woocommerce_template_single_title(); ?>

<div class="product-summary__subheader">
<div class="product-summary__sold">
Sold <span><?= $total_sales ?></span>
</div>
<?php woocommerce_template_single_rating(); ?>
</div>

<?php
// do_action('woocommerce_single_product_summary');
woocommerce_template_single_title();
woocommerce_template_single_rating();
woocommerce_template_single_price();
woocommerce_template_single_add_to_cart();
woocommerce_template_single_excerpt();
Expand Down

0 comments on commit d7b3d83

Please sign in to comment.