Skip to content

Instantly share code, notes, and snippets.

@unlocomqx
Created October 17, 2022 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unlocomqx/d3cf4a90a8e5a41fc5be65b9de33c4db to your computer and use it in GitHub Desktop.
Save unlocomqx/d3cf4a90a8e5a41fc5be65b9de33c4db to your computer and use it in GitHub Desktop.
<?php
// Pseudo code
// Attibute quantity coefficient map
// it only contains attrA and attrB because other attributes are more dynamic
$attr_qty_map = array(
'attrA' => 1,
'attrB' => 2,
'attrE' => 0,
);
// dynamic qty
$attr_qty_map['attrC'] = $other_field * $oplage;
$attr_qty_map['attrD'] = $dynamic_field * 10 + $oplage;
if ($field_checkbox) {
$attr_qty_map['attrE'] = $oplage * 10;
}
// I pass in 'attrA', but it should be $id_attriute_A
$attibute_attrA = getTierPrice('attrA', $attr_qty_map['attrA']);
$attibute_attrB = getTierPrice('attrB', $attr_qty_map['attrB']);
$attibute_attrC = getTierPrice('attrC', $attr_qty_map['attrC']);
$attibute_attrD = getTierPrice('attrD', $attr_qty_map['attrD']);
$attibute_attrE = getTierPrice('attrE', $attr_qty_map['attrE']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment