Question: Update Product Price

Update Product Price

While Purchasing a product we will able to update its cost. I would like to update product price also while purchase. I checked on purchase controller and i didn't find way to get done this.

TS

Thimera Silva

Asked
While Purchasing a product we will able to update its cost. I would like to update product price also while purchase. I checked on purchase controller and i didn't find way to get done this. Is that currently runs through ajax ? Can you inform me where can i find code related to this function of update cost while purchasing ?
  • MS

    Mian Saleem

    Answered
    Hello,

    There is no option to update the price with purchase. You can update bulk products' price by csv or import products.

    If you want to modify the code, you can edit `addPurchase` method of the `app/models/admin/Purchases_model.php`

    Thank you
  • TS

    Thimera Silva

    Answered
    In the Settings I can find 'Update cost with purchase'. If it make to yes it will update cost of product while purchasing product. Can you let me know when is that value is checking on this purchase function. So i can get build it my self.
  • TS

    Thimera Silva

    Answered
    ok I found it and i was able to get done this
    Thanks for the support
  • TS

    Thimera Silva

    Answered
    I have one more request,

    If i create a new form-group and get a new variable into purchase, how to get post that value into purchase controller ? I have got written each function as well as, but i'm having issue with post method of that value, it's not getting post into post controller, I think your post method works on here with js or ajax. please let me know how can i get post it. Thanks
  • MS

    Mian Saleem

    Answered
    Hello,

    You can get post value in controller as `$this->input->post('fieldName')` For help please refer to **[CodeIgniter v3 User Guide](https://codeigniter.com/userguide3/libraries/input.html?highlight=post#CI_Input::post)**.

    Thank you
  • TS

    Thimera Silva

    Answered
    I know that how it works, In my case check my Screen shot c1. There i have placed a form group which called 'product_price'
    In c2 you will see how it looks.

    Check C3 for my purchase controller. Issue is that my product_price value is not getting posted into controller.
    If i placed unit_price on there its comming.

    So i think there on c1 values comes through Js or ajax. I can see 'pcost' id and its related to unit_cost. how can i get assign 'pprice' into product_price and get posted into controller ? or is there any otherway i can get done this ?

    If possible let me know. So i will able to update product price while purchasing that.

    Thanks
  • MS

    Mian Saleem

    Answered
    Hello,

    All modal inputs are handled in the javascript those are not direct pass to form. You can check the `themes/default/admin/assets/js/purchases.js` to see how modal inputs are handled and pass to the form. On open modal, the cost is assigned to pcost field and on close it is passed back to the poitems and loaded to form in loaditems function.

    Thank you
  • Login to Reply