Service Portal Add to Cart Issue

Blair5
Tera Guru

We are on Helsinki Patch 11 and have the cart showing on our service portal. When a user fills out the fields on a cat item and adds to cart, the ability to change some of those fields and add again isn't working. I saw a mention in another post - Add to Cart functionality for Service Portal - where you can disable this, but I don't see how. Any help? This featured is used pretty regularly by our users.

1 ACCEPTED SOLUTION

Hi Blair,



Now that we know it the same code and disabled in all.. I thought let me figure this   and found it



Some steps



  • Clone the sc catalog item widget (else it is read only)
  • Attache the cloned widget the the Service catalog page
  • Look for the ng-disabled="submitted" on the line containing Add to cart and DELETE the   ng-disabled="submitted"


find_real_file.png


  • You also need to make changes to the client script highlighted below (EDIT Updated code to fix submit greyed out after add)
  • find_real_file.png

I didnt test for other side effects but add to cart works and does not get disabled after adding


Let us know how it goes. breinhart


Mine...


find_real_file.png


View solution in original post

27 REPLIES 27

Hi Blair,



Basically, we can hide the add to cart button based on if submitted is true or false. Change the below HTML :



<button   tabindex="0" ng-if="c.showAddCartBtn()" name="submit"     ng-click="triggerAddToCart()" class="btn btn-default">${Add to Cart}</button>


to


<button   tabindex="0" ng-if="!submitted && c.showAddCartBtn()" name="submit"     ng-click="triggerAddToCart()" class="btn btn-default">${Add to Cart}</button>



If you wanted to disable:


<button   tabindex="0" ng-if="c.showAddCartBtn()" name="submit" ng-disabled="submitted"   ng-click="triggerAddToCart()" class="btn btn-default">${Add to Cart}</button>


   


Ravindran,



Perfect! Thank you again!


Hi Ravindran,



Can the submit button be hidden once 'add to cart' is clicked? I tried adding ng-disabled to this line with no luck:



<button ng-if = "!addToCart" name="submit" ng-disabled="submitted" ng-click="triggerOnSubmit()" class="btn btn-primary">{{submitButtonMsg}}</button>


<button ng-if="!submitted && c.showAddCartBtn()" name="submit" ng-disabled="addToCart" ng-click="triggerAddToCart()" class="btn btn-default">${Add to Cart}</button>


Hi Blair,



You may have to edit the html:



<button ng-if="!added && c.showOrderNowButton()" tabindex="0" name="submit" ng-disabled="submitted" ng-click="triggerOnSubmit()" class="btn btn-primary">{{submitButtonMsg}}</button>



And update client controller:



function addToCart() {


postCatalogFormRequest(true).success(function(response) {


$rootScope.$broadcast("$sp.service_catalog.cart.add_item");


$rootScope.$broadcast("$sp.service_catalog.cart.update");


//spUtil.addInfoMessage("Added item to shopping cart");


$scope.submitting = false;


c.status = "Added item to shopping cart";


$scope.added = true; //add this line


});


}



But reloading a page will reset the status and the submit button will be enabled.


More work might be needed if you want the page reload to consider items in cart:


* Check quantity > 1 and set the $scope.added to true (this seems tricky)


Hi Ravindran,



That seemed to have worked. I want the submit to be there if they reload the form or open a new form. They have the option of either/or. If they select submit, then add to cart is gone, and if they add to cart then submit is gone. Will do more testing.