-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log secret helper errors in case debug modus is enabled. Added mini c…
…art block adjustments. Automatically activate subscriptions for invoice gateway after processing renewals.
- Loading branch information
1 parent
baaa2b7
commit ae74321
Showing
18 changed files
with
401 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
ul.wc-block-components-product-details { | ||
li[class*="wc-block-components-product-details__gzd-"] { | ||
.wc-block-components-product-details__name { | ||
display: none; | ||
} | ||
.wc-block-components-product-details__value { | ||
font-size: .8rem; | ||
color: #757575; | ||
} | ||
} | ||
} | ||
|
||
.wc-gzd-small-business-info { | ||
font-size: .8rem; | ||
color: #757575; | ||
} | ||
|
||
.wc-gzd-unit-price { | ||
font-weight: normal; | ||
font-size: .8rem; | ||
color: #757575; | ||
|
||
.wc-block-components-product-details__name { | ||
display: none; | ||
} | ||
} | ||
|
||
ul.wc-block-components-product-details { | ||
li.wc-block-components-product-details__gzd-unit-price { | ||
display: none !important; | ||
} | ||
|
||
li.wc-not-gzd-summary-item-first { | ||
margin-top: 1em; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import MINI_CART_NOTICES from './mini-cart-notices/block.json'; | ||
|
||
export default { | ||
MINI_CART_NOTICES | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './style.scss'; | ||
import './register-components'; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"apiVersion": 2, | ||
"name": "woocommerce-germanized/mini-cart-notices", | ||
"version": "2.0.0", | ||
"title": "Mini cart legal notices", | ||
"category": "woocommerce", | ||
"description": "Outputs mini cart legal notices.", | ||
"supports": { | ||
"align": false, | ||
"html": false, | ||
"multiple": false, | ||
"reusable": false, | ||
"inserter": true, | ||
"color": { | ||
"text": true, | ||
"background": true | ||
} | ||
}, | ||
"parent": [ "woocommerce/mini-cart-footer-block" ], | ||
"textdomain": "woocommerce-germanized", | ||
"attributes": { | ||
"lock": { | ||
"type": "object", | ||
"default": { | ||
"remove": false, | ||
"move": false | ||
} | ||
} | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
assets/js/blocks/mini-cart/mini-cart-notices/frontend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { useEffect, useState } from "@wordpress/element"; | ||
import { getSetting } from '@germanized/settings'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { CART_STORE_KEY } from '@woocommerce/block-data'; | ||
|
||
import './style.scss'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
const Block = ({ | ||
className | ||
}) => { | ||
const displayCartPricesIncludingTax = getSetting( | ||
'displayCartPricesIncludingTax', | ||
false | ||
); | ||
|
||
const showTaxNotice = getSetting( | ||
'showMiniCartTaxNotice', | ||
true | ||
); | ||
|
||
const showShippingCostsNotice = getSetting( | ||
'showMiniCartShippingCostsNotice', | ||
true | ||
); | ||
|
||
const isSmallBusiness = getSetting( | ||
'isSmallBusiness', | ||
false | ||
); | ||
|
||
const smallBusinessNotice = getSetting( | ||
'smallBusinessNotice', | ||
'' | ||
); | ||
|
||
const cart = useSelect( | ||
( select, { dispatch } ) => { | ||
const store = select( CART_STORE_KEY ); | ||
const cartData = store.getCartData(); | ||
const cartErrors = store.getCartErrors(); | ||
const cartTotals = store.getCartTotals(); | ||
const cartIsLoading = | ||
! store.hasFinishedResolution( 'getCartData' ); | ||
|
||
const { receiveCart, receiveCartContents } = dispatch( CART_STORE_KEY ); | ||
const gzdDefaultData = { | ||
'shipping_costs_notice': '' | ||
}; | ||
|
||
const gzdData = cartData.extensions.hasOwnProperty( 'woocommerce-germanized' ) ? cartData.extensions['woocommerce-germanized'] : gzdDefaultData; | ||
const gzdTaxNotice = displayCartPricesIncludingTax ? __( 'incl. VAT', 'woocommerce-germanized' ) : __( 'excl. VAT', 'woocommerce-germanized' ); | ||
|
||
return { | ||
cartItems: cartData.items, | ||
crossSellsProducts: cartData.crossSells, | ||
cartItemsCount: cartData.itemsCount, | ||
cartItemsWeight: cartData.itemsWeight, | ||
cartNeedsPayment: cartData.needsPayment, | ||
cartNeedsShipping: cartData.needsShipping, | ||
cartItemErrors: cartData.errors, | ||
cartTotals, | ||
cartIsLoading, | ||
cartErrors, | ||
extensions: cartData.extensions, | ||
shippingRates: cartData.shippingRates, | ||
cartHasCalculatedShipping: cartData.hasCalculatedShipping, | ||
paymentRequirements: cartData.paymentRequirements, | ||
shippingCostsNotice: cartData.needsShipping ? gzdData.shipping_costs_notice : '', | ||
taxNotice: cartTotals.total_tax > 0 ? gzdTaxNotice : '', | ||
receiveCart, | ||
receiveCartContents, | ||
}; | ||
}, | ||
[ displayCartPricesIncludingTax ] | ||
); | ||
|
||
console.log( cart ); | ||
|
||
return ( | ||
<div className="wc-gzd-block-mini-cart-notices"> | ||
{ isSmallBusiness && smallBusinessNotice && ! showTaxNotice && | ||
<div className="wc-gzd-block-mini-cart-notices__notice wc-gzd-block-mini-cart-notices__small-business-notice" | ||
dangerouslySetInnerHTML={ { | ||
__html: smallBusinessNotice, | ||
} } | ||
> | ||
</div> | ||
} | ||
<div className="wc-gzd-block-mini-cart-notices__notice-wrap"> | ||
{ cart.taxNotice && showTaxNotice && | ||
<div className="wc-gzd-block-mini-cart-notices__notice wc-gzd-block-mini-cart-notices__tax-notice" | ||
dangerouslySetInnerHTML={ { | ||
__html: cart.taxNotice, | ||
} } | ||
> | ||
</div> | ||
} | ||
{ cart.shippingCostsNotice && showShippingCostsNotice && | ||
<div className="wc-gzd-block-mini-cart-notices__notice wc-gzd-block-mini-cart-notices__shipping-notice" | ||
dangerouslySetInnerHTML={ { | ||
__html: cart.shippingCostsNotice, | ||
} } | ||
> | ||
</div> | ||
} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default Block; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.wc-block-mini-cart__footer-actions { | ||
flex-wrap: wrap; | ||
|
||
.wc-gzd-block-mini-cart-notices { | ||
justify-content: right; | ||
margin-top: -7px; | ||
font-size: 0.8rem; | ||
color: #757575; | ||
flex: 0 0 100%; | ||
display: inline-flex; | ||
text-align: right; | ||
flex-wrap: wrap; | ||
|
||
.wc-gzd-block-mini-cart-notices__notice { | ||
&::after { | ||
content: "\00a0"; | ||
} | ||
|
||
&.wc-gzd-block-mini-cart-notices__small-business-notice { | ||
flex: 0 0 100%; | ||
} | ||
} | ||
|
||
.wc-gzd-block-mini-cart-notices__notice-wrap { | ||
text-align: left; | ||
display: flex; | ||
justify-content: right; | ||
flex: 0 0 100%; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { registerCheckoutBlock } from '@woocommerce/blocks-checkout'; | ||
import { lazy } from '@wordpress/element'; | ||
|
||
import metadata from './component-metadata'; | ||
|
||
registerCheckoutBlock({ | ||
metadata: metadata.MINI_CART_NOTICES, | ||
component: lazy( | ||
() => | ||
import( | ||
/* webpackChunkName: "mini-cart-blocks/mini-cart-notices" */ './mini-cart-notices/frontend' | ||
) | ||
), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import '../cart-checkout/items'; | ||
|
||
.wc-block-components-totals-item__description { | ||
display: none !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.