diff --git a/Blocks/woo-vipps-blocks.php b/Blocks/woo-vipps-blocks.php index c500be7..7614923 100644 --- a/Blocks/woo-vipps-blocks.php +++ b/Blocks/woo-vipps-blocks.php @@ -2,36 +2,30 @@ // This is the new script to register blocks built into ./dist. At this time only the vipps-badge block. LP 19.11.2024 -/** - * Init hooks and inline script for the block vipps-badge. LP 14.11.2024. - * - * @return void - */ -function vipps_badge_block_hooks() { - add_action('init', function () { +add_action('init', function () { register_block_type(__DIR__ . '/dist/vipps-badge'); - }); +}); - // Inject block config variables to vipps-badge editor script. LP 15.11.2024 - add_action('enqueue_block_editor_assets', function () { +// Inject block config variables to vipps-badge editor script. LP 15.11.2024 +add_action('enqueue_block_editor_assets', function () { $vipps = Vipps::instance(); $variants = $variants = [ - ['label' => __('White', 'woo-vipps'), 'value' => 'white'], - ['label' => __('Grey', 'woo-vipps'), 'value' => 'grey'], - ['label' => __('Filled', 'woo-vipps'), 'value' => 'filled'], - ['label' => __('Light', 'woo-vipps'), 'value' => 'light'], - ['label' => __('Purple', 'woo-vipps'), 'value' => 'purple']]; + ['label' => __('White', 'woo-vipps'), 'value' => 'white'], + ['label' => __('Grey', 'woo-vipps'), 'value' => 'grey'], + ['label' => __('Filled', 'woo-vipps'), 'value' => 'filled'], + ['label' => __('Light', 'woo-vipps'), 'value' => 'light'], + ['label' => __('Purple', 'woo-vipps'), 'value' => 'purple']]; // Set a default language for the vipps-badge. LP 21.11.2024 $store_language = substr(get_bloginfo('language'), 0, 2); if ($store_language == 'nb' || $store_language == 'nn') { - $store_language = 'no'; + $store_language = 'no'; } if ($store_language == 'da') { - $store_language = 'dk'; + $store_language = 'dk'; } if (!in_array($store_language, ['en', 'no', 'dk', 'fi'])) { - $store_language = 'en'; + $store_language = 'en'; } // english default fallback $block_config = [ @@ -50,10 +44,9 @@ function vipps_badge_block_hooks() { ], ]; - wp_add_inline_script('woo-vipps-vipps-badge-editor-script', - 'const injectedVippsBadgeBlockConfig = ' . json_encode($block_config), - 'before'); - }); -} + wp_add_inline_script('woo-vipps-vipps-badge-editor-script', + 'const injectedVippsBadgeBlockConfig = ' . json_encode($block_config), + 'before'); +}); + -vipps_badge_block_hooks(); diff --git a/Vipps.class.php b/Vipps.class.php index 051b8a0..45a6c39 100644 --- a/Vipps.class.php +++ b/Vipps.class.php @@ -398,29 +398,6 @@ public function maybe_add_vipps_badge_feature () { } - // Comment out vipps-senere stuff. LP 18.11.2024 - // $price = 0; - // $supported_currencies = ['NOK']; - // $currency = get_woocommerce_currency(); - // if ($product && in_array($currency, $supported_currencies)) { - // // Currently only supports NOK! 2022-11-11 IOK - // $price = $product->get_price(); - // $price = round($price * 100); - // $attr .= " amount ='". $price. "' "; - // } - - // $showlater = @$badge_options['later'] && $price>=intval(@$badge_options['minLater']); - // $showlaterforthis = $product->get_meta('_vipps_badge_pay_later', true); - // if ($showlaterforthis == 'no') { - // $showlater = false; - // } else if ($showlaterforthis == 'later') { - // $showlater = true; - // } - - // if (apply_filters('woo_vipps_product_badge_show_later', $showlater, $product)) { - // $attr .= " vipps-senere='" . sanitize_title($badge_options['later']) . "' "; - // } - $lang = $this->get_customer_language(); if ($lang) { $attr .= " language='". $lang . "' "; @@ -748,9 +725,7 @@ public function badge_menu_page () { - -> + >

@@ -765,21 +740,6 @@ public function badge_menu_page () { - - - - - value="1" type="checkbox" id="vippsLater" name="later" />
-
-
- - - /> -
- */ ?> -
@@ -794,8 +754,7 @@ public function badge_menu_page () {

documented here) or you can use the shortcode.', 'woo-vipps'), Vipps::CompanyName(), "https://developer.vippsmobilepay.com/docs/knowledge-base/design-guidelines/on-site-messaging/"); ?>



-
[vipps-mobilepay-badge variant={white|filled|light|grey|purple}
language={en|no|fi|dk}]

+
[vipps-mobilepay-badge variant={white|filled|light|grey|purple}
language={en|no|fi|dk} ]


@@ -814,21 +773,6 @@ function changeVariant() { badge.remove(); holder.appendChild(newbadge); } - // Comment out vipps-senere stuff. LP 18.11.2024 - // function changeLater() { - // let badge = document.getElementById('vipps-badge-demo'); - // let later = document.getElementById('vippsLater').checked; - // if (later) { - // badge.setAttribute('vipps-senere', true); - // } else { - // badge.removeAttribute('vipps-senere'); - // } - // let holder = document.getElementById('badgeholder'); - // let newbadge = badge.cloneNode(); - // badge.remove(); - // holder.appendChild(newbadge); - // } - '', 'class'=>'', 'variant' => '','language'=>'','amount' => '', 'vipps-senere'=>''), $atts ); - $args = shortcode_atts( array('id'=>'', 'class'=>'', 'brand' => '', 'variant' => '','language'=>''), $atts ); $variant = in_array($args['variant'], ['orange', 'light-orange', 'grey','white', 'purple', 'filled', 'light']) ? $args['variant'] : ""; @@ -896,23 +830,16 @@ public function vipps_mobilepay_badge_shortcode($atts) { // legacy vipps_badge shortcode. LP 19.11.2024 public function vipps_badge_shortcode($atts) { - // comment out vipps-senere stuff. LP 19.11.2024 - // $args = shortcode_atts( array('id'=>'', 'class'=>'', 'variant' => '','language'=>'','amount' => '', 'vipps-senere'=>''), $atts ); - $args = shortcode_atts( array('id'=>'', 'class'=>'','variant' => '','language'=>''), $atts ); $variant = in_array($args['variant'], ['orange', 'light-orange', 'grey','white', 'purple']) ? $args['variant'] : ""; $language = in_array($args['language'], ['en','no', 'dk', 'fi']) ? $args['language'] : $this->get_customer_language(); - // $amount = intval($args['amount']); - // $later = $args['vipps-senere']; $id = sanitize_title($args['id']); $class = sanitize_text_field($args['class']); $attributes = []; if ($variant) $attributes['variant'] = $variant; if ($language) $attributes['language'] = $language; - // if ($amount) $attributes['amount'] = $amount; - // if ($later) $attributes['vipps-senere'] = 1; if ($id) $attributes['id'] = $id; if ($class) $attributes['class'] = $class; @@ -1428,11 +1355,6 @@ public function process_product_meta ($id, $post) { update_post_meta($id, '_vipps_show_badge', sanitize_text_field($_POST['woo_vipps_show_badge'])); } - // Comment out vipps-senere stuff. LP 18.11.2024 - // if (isset($_POST['woo_vipps_badge_pay_later'])) { - // update_post_meta($id, '_vipps_badge_pay_later', sanitize_text_field($_POST['woo_vipps_badge_pay_later'])); - // } - // This is for the shareable links. if (isset($_POST['woo_vipps_shareable_delenda'])) { $delenda = array_map('sanitize_text_field',$_POST['woo_vipps_shareable_delenda']); @@ -1514,9 +1436,6 @@ public function product_options_vipps_badges() { echo "

"; $showbadge = sanitize_text_field(get_post_meta( get_the_ID(), '_vipps_show_badge', true)); - // Comment out vipps-senere stuff. LP 18.11.2024 - // $later = sanitize_text_field(get_post_meta( get_the_ID(), '_vipps_badge_pay_later', true)); - woocommerce_wp_select( array( 'id' => 'woo_vipps_show_badge', @@ -1533,20 +1452,6 @@ public function product_options_vipps_badges() { 'value' => $showbadge ) ); - - // Comment out vipps-senere stuff. LP 18.11.2024 - // woocommerce_wp_select( - // array( - // 'id' => 'woo_vipps_badge_pay_later', - // 'label' => sprintf(__( 'Override %1$s Later', 'woo-vipps' ), $this->get_payment_method_name()), - // 'options' => array( - // '' => __('Default setting', 'woo-vipps'), - // 'later' => sprintf(__('Use %1$s Later', 'woo-vipps'), $this->get_payment_method_name()), - // 'no' => sprintf(__('Do not use %1$s Later', 'woo-vipps'), $this->get_payment_method_name()), - // ), - // 'value' => $later - // ) - // ); echo "
"; } diff --git a/VippsWCProductEditorV2.class.php b/VippsWCProductEditorV2.class.php index bfa3bf1..e56daa6 100644 --- a/VippsWCProductEditorV2.class.php +++ b/VippsWCProductEditorV2.class.php @@ -189,26 +189,6 @@ public function init_woo_vipps_product_tab($general_group) ] ); - // Comment out vipps-senere stuff. LP 18.11.2024. - // $badges_section->add_block( - // [ - // 'id' => 'woo-vipps-overrides-later', - // 'blockName' => 'woocommerce/product-select-field', - // 'order' => 3, - // 'attributes' => [ - // 'label' => sprintf(__('Override %1$s Later', 'woo-vipps'), $payment_method_name), - // 'property' => 'meta_data._vipps_badge_pay_later', - // 'autoFocus' => false, - // 'help' => __('Choose if this product should use Vipps Later', 'woo-vipps'), - // 'options' => array( - // ['value' => '', 'label' => __('Default setting', 'woo-vipps')], - // ['value' => 'later', 'label' => sprintf(__('Use %1$s Later', 'woo-vipps'), $payment_method_name)], - // ['value' => 'no', 'label' => sprintf(__('Do not use %1$s Later', 'woo-vipps'), $payment_method_name)], - // ), - // ], - // ] - // ); - if ($payment_method_name == "Vipps") { // Buy now section $buy_now_section = $gr->add_section(