我正在尝试找到一种将客户文本属性拆分以在前端显示的方法。

我已经在客户地址添加了一个新的文本字段,并希望在View.phtml文件中的前端显示此值。问题在于,该值根据欧元的客户位置而存储为字符串,我们有€| c,对于英国,我们在该领域存储了£| p。

我需要如何将此值分开以在单独的位置显示。

我正在使用jQuery来验证前端上的价格形式。来自欧盟的客户需要显示€| c值,英国客户需要从TextAttribute中显示£| p。

因此,我需要以某种方式将客户属性显示在 product/view.phtml 然后归档拆分阵列()

这是我的代码:

    if (x<100) {
        //c OR p Value needs to go here
        validOptions.push( "<?php echo $address->getCurrency(); ?>"+x+"");
    } else {
        var y = x.toString();
        var z = y.split('');
        //£ OR € Value needs to go here
        validOptions.push("<?php echo $address->getCurrency(); ?>"+z[0]+"."+z[1]+""+z[2]+"");
    }
    x++;

有人知道该怎么做,请给我一个人...

有帮助吗?

解决方案

使用以下片段来检索您的属性并将其拆分 |

$currency = Mage::getSingleton('customer/session')->getCustomer()->getData('your-custom-attributecode');
$currency_split = explode('|', $currency);

其他提示

谢谢,这很好..

<?php $split = explode('|', $address->getCurrency());
  echo $split[0]; ?>"+z[0]+"."+z[1]+""+z[2]+"?>
许可以下: CC-BY-SA归因
scroll top