| 1 |
( function( wp ) { |
| 2 |
|
| 3 |
if (!wp) return; |
| 4 |
if (typeof(wp['blocks']) == 'undefined') return; |
| 5 |
if (typeof(wp['element']) == 'undefined') return; |
| 6 |
|
| 7 |
const { getCategories, registerBlockType, setCategories } = wp.blocks; |
| 8 |
var el = wp.element.createElement; |
| 9 |
var __ = wp.i18n.__; |
| 10 |
|
| 11 |
|
| 12 |
const VippsBuyNow = ( props ) => { |
| 13 |
return el('div', {"class": 'wp-block-button wc-block-components-product-button wc-block-button-vipps'}, |
| 14 |
el ('a', {"javascript":'void(0)', "data-product_id":props.product.id, |
| 15 |
"class": "single-product button vipps-buy-now wp-block-button__link", |
| 16 |
"title":VippsConfig['BuyNowWithVipps']}, |
| 17 |
el('span', { "class": "vippsbuynow" }, VippsConfig['BuyNowWith']), |
| 18 |
el('img', { "class":"inline vipps-logo negative", |
| 19 |
"src":VippsConfig['vippslogourl'], |
| 20 |
"alt":"Vipps", "border":0}))); |
| 21 |
}; |
| 22 |
|
| 23 |
|
| 24 |
const blockConfig = { |
| 25 |
category: 'woocommerce', |
| 26 |
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ], |
| 27 |
supports: { |
| 28 |
html: false, |
| 29 |
}, |
| 30 |
parent: [ 'woocommerce/all-products' ], |
| 31 |
icon: el('img', {"class": "vipps-smile vipps-component-icon", "src": VippsConfig['vippssmileurl'] }), |
| 32 |
title: VippsConfig['vippsbuynowbutton'], |
| 33 |
description: VippsConfig['vippsbuynowdescription'], |
| 34 |
edit: function( props ) { |
| 35 |
return el(VippsBuyNow, { product: {} } ); |
| 36 |
} |
| 37 |
}; |
| 38 |
|
| 39 |
registerBlockType( 'vipps/buy-now', blockConfig ); |
| 40 |
|
| 41 |
}( |
| 42 |
window.wp |
| 43 |
) ); |
| 44 |
|
| 45 |
|
| 46 |
|