Magento:如何显示可配置重复产品的重复配置文件信息

标签 magento magento-1.7 recurring-billing

我创建了一个可配置产品,允许用户在产品的重复版本和非重复版本之间进行选择(每个版本都是一个简单的产品)。我遇到的问题是,当用户选择重复选项时,他们不会看到他们在简单的重复产品中看到的重复配置文件信息。如何让 Magento 有条件地为可配置产品显示此信息?

最佳答案

这是一个可行的解决方案,是通过一些幸运的猜测得出的。

// check to see if the product is configurable
if ( $_product->getTypeID() == 'configurable' ) {
    // get the associated products    
    $associatedProducts = $_product->getTypeInstance()->getUsedProducts();
    // iterate through the products, checking for recurring products
    foreach ( $associatedProducts as $associatedProduct ) {
        if ($associatedProduct->isRecurring()) {
            // get the recurring profile
            $profile = $associatedProduct->getRecurringProfile();
            // echo whichever array members you need
            echo '<p>billed '.$profile['period_frequency'].' time(s) per '.$profile['period_unit'].'</p>';
        }
    }
}

我在这里得到了一些帮助:http://www.phptechi.com/how-to-get-associated-child-product.html

然后我刚刚对 getRecurringProfile() 进行了一个幸运的方法名称猜测。

var_dump($linkedProduct->getRecurrringProfile()) 产量:

array(13) { 
["start_date_is_editable"]=> string(1) "1" 
["schedule_description"]=> string(0) "" 
["suspension_threshold"]=> string(0) "" 
["bill_failed_later"]=> string(1) "1" ["period_unit"]=> string(5) "month"        
["period_frequency"]=> string(1) "1" ["period_max_cycles"]=> string(0) "" 
["trial_period_unit"]=> string(0) "" ["trial_period_frequency"]=> string(0) "" 
["trial_period_max_cycles"]=> string(0) "" ["trial_billing_amount"]=> string(0) "" 
["init_amount"]=> string(0) "" ["init_may_fail"]=> string(1) "0" 
}

关于Magento:如何显示可配置重复产品的重复配置文件信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15531348/

相关文章:

magento - block toHTML 导致内存泄漏

php - Paypal 定期付款停止

sql - 仓库管理经常性计费数据库设计和逻辑

php - 以编程方式 magento 管理连接不起作用

magento - magento中sales_flat_order中base_stuff和stuff的区别

magento-1.7 - 第 : 行中属性集列的值无效(集不存在?)

php - 在不符合 PCI 的情况下通过 PayPal 定期借记卡/信用卡付款

magento - 如何将产品 View 页面更改为一列布局

magento - 如何在 Magento 的保存事件中扩展 CMS Block?