2

I am new in magento and hybrid mobile app. I have created the hybrid mobile app but when i want to buy a configurable product. Then a message i got that the "Please the product option" , Kindly guide me how to send the product selected option to buy the product.

HTMl Code :-

{{product.product.name}} 1"> Unit Price : {{product.product.price_list.prices.price[0]._formatted_value}} 1"> You Pay : {{product.product.price_list.prices.price[1]._formatted_value}} Unit Price : {{product.product.price_list.prices.price._formatted_value}}

 <div ng-if="product.product.product.options.option.length > 1">
     <ion-item class="item item-dark">
        <strong>Product Options:</strong>
     </ion-item>
     <label class="item item-stable item-input item-select" ng-repeat="option in product.product.product.options.option">
        <div class="input-label">
           {{option._label}}
        </div>
        <select ng-modal="opt">
           <option></option>
           <option ng-repeat="value in option.value" value="{{value._code}}">{{value._label}} {{value._formated_price}}</option>
        </select>
     </label>
  </div>


<div ng-if="product.product.product.options.option != null && !product.product.product.options.option.length">
     <ion-item class="item item-dark">
        <strong>Product Options:</strong>
     </ion-item>
     <label class="item item-stable item-input item-select" ng-repeat="option in product.product.product.options">
        <div class="input-label">
           {{option._label}}
        </div>
        <select ng-model= "super_attribute[159]">
           <option></option>
           <option ng-repeat="value in option.value" value="{{value._code}}">{{value._code}}</option>
        </select>
     </label>
 </div>

  <ion-item class="item-light item-text-wrap">
     <strong>Description:</strong>
     </br>
     {{product.product.short_description}}
  </ion-item>
  <ion-item class="item item-dark">
     <strong>Addition Info</strong>
  </ion-item>
  <ion-item ng-repeat="item in product.product.additional_attributes.item">
     <strong>{{item.label}}: </strong> {{item.value}}
  </ion-item>

Buy Now Add to Cart

Java Code:-

//Add Item to Cart
$scope.addtocart = function(entity_id) {

    var req = {
        method: 'POST',
        url: appService.url + '/xmlconnect/cart/add/?' + "options[7]=16",
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        data: $.param({
            product: entity_id
        }),
    }

    $http(req).then(function(response) {
        var x2js = new X2JS();
        $scope.message = x2js.xml_str2json(response.data);
        appService.showAlert($scope.message.message.status, $scope.message.message.text);

        if ($scope.message.message.status == 'success') {
            $rootScope.cartItemCount++
        };

    }, function(response) {

    });
}

//Perfom Buy item Action
$scope.buyNow = function(entity_id) {

    var req = {
        method: 'POST',
        url: appService.url + '/xmlconnect/cart/add/',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        data: $.param({
            product: entity_id
        }),
    }

    $http(req).then(function(response) {
        var x2js = new X2JS();
        $scope.message = x2js.xml_str2json(response.data);
        appService.showAlert($scope.message.message.status, $scope.message.message.text);

        if ($scope.message.message.status == 'success') {
            $rootScope.cartItemCount++;
            window.location = "#/app/checkout";
        };

    }, function(response) {

    });
}

}])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.