Skip to content

Commit

Permalink
PES-2228: fillRateAttrValues extracted
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-potuznik-z committed Sep 16, 2024
1 parent 838695f commit a332a93
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 49 deletions.
2 changes: 1 addition & 1 deletion public/block/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wc-blocks-checkout', 'wc-blocks-components', 'wc-settings', 'wp-block-editor', 'wp-blocks', 'wp-data', 'wp-i18n'), 'version' => 'f764441bfe2d788f5370');
<?php return array('dependencies' => array('react', 'wc-blocks-checkout', 'wc-blocks-components', 'wc-settings', 'wp-block-editor', 'wp-blocks', 'wp-data', 'wp-i18n'), 'version' => '2dc2ca82076e7852d03b');
2 changes: 1 addition & 1 deletion public/block/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions src/PacketaWidget/fillRateAttrValues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const fillRateAttrValues = function ( carrierRateId, data, source, rateAttrValues ) {
for ( let attrKey in data ) {
if ( ! data.hasOwnProperty( attrKey ) ) {
continue;
}

const { name, widgetResultField, isWidgetResultField } =
data[ attrKey ];

if ( false === isWidgetResultField ) {
continue;
}

let widgetField = widgetResultField || attrKey;
let addressFieldValue = source[ widgetField ];

rateAttrValues[ carrierRateId ] =
rateAttrValues[ carrierRateId ] || {};
rateAttrValues[ carrierRateId ][ name ] = addressFieldValue;
}

return rateAttrValues;
};
Loading

0 comments on commit a332a93

Please sign in to comment.