PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, June 30, 2022

[FIXED] How to change product name in the cart in Prestashop?

 June 30, 2022     e-commerce, php, prestashop     No comments   

Issue

I want to change the names of some products in the cart. I was able to change the price of some products in the cart. But i can't change the names of some products in the cart.

How can i do that? Is it possible. Thanks for helps.

For your better understanding, below is some of the result from cart->getProducts() action.

enter image description here


Solution

I solved the problem with the code below. If you encounter this problem, you can edit the code below for yourself. And you must do these actions after validateOrder function or validated the order.

        $order = Order::getByCartId($cart->id);

        $order_details = OrderDetail::getList($order->id);


        foreach ($order_details as $order_detail) {
            if ($order_detail['product_name'] === 'Installment' && (string)$order_detail['product_price'] == (string)$installment_fee) {
                $order_detail_id = $order_detail['id_order_detail'];
            }
        }

        if (!is_null($order_detail_id)) {
            $order_detail = new OrderDetail($order_detail_id);
            $order_detail->product_name = 'Changed product name';
            $order_detail->save();
        }


Answered By - emrez
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing