获取IONIC中的Woocommerce产品属性/变体

时间:2016-11-09 16:11:02

标签: wordpress api ionic-framework woocommerce woocommerce-rest-api

我需要一些帮助。 我正在尝试获取产品的属性和变体。以下是我所做的一切:

product.html

<div class="list card">
            <div class="item item-body" ng-repeat="attribute in product.attributes">
                <h2>{{attribute.name}}</h2>

                <ion-radio ng-repeat="variation in product.variations">
                  {{variation.price}}
                  <div ng-repeat="vaAttribute in variation.attributes">                    
                  {{vaAttribute.option}}
                  </div>
                    </ion-radio>
              </div>
        </div>

controller.js

     .controller('ProductCtrl', function($scope, WC, $stateParams, $ionicSlideBoxDelegate, $localStorage, $rootScope){

      var Woocommerce = WC.WC();

      Woocommerce.get('products/' + $stateParams.productID, function(err, data, res){
        if(err)
          console.log(err);

        $scope.product = JSON.parse(res).product;
        $scope.images = JSON.parse(res).product.images;

........................................................
........................................................

如果我有一个带变体的属性,它可以正常工作。 但是如果我有多个属性,它将打印循环中所有属性的所有变体。

see image

0 个答案:

没有答案
相关问题