-1

In magento checkout page, after giving billing information and shipping information, i understand that these details are sending to fedex then the shipping rates are populating in chekout page, before sending theses details to fedex, i want to change the weight of the product, i Want to add additional weights for each products,

suppose user adding a product with weight of 2 pounds, i want to send these weight to 2*5 = 10pounds, how can i do that in magento? please help.

Naveenbos
  • 2,532
  • 3
  • 34
  • 60

2 Answers2

0

Not sure to understand what you want exactly but I'll give a try.

I think you can override Mage_Checkout_OnepageController::savePaymentAction method in your local pool and in your local method, dispatch your own new event 'save_payment_action_before' and pass your objects as parameters.

In your fedex module, create an observer, get your object and change the order weight before it's sent to fedex.

To create your custom event, check this post

Community
  • 1
  • 1
beluga
  • 193
  • 3
  • 17
  • In magento cart page and checkout page, after giving billing information and shipping information, i understand that these details were sending to fedex, then the shipping rates were populating in cart page and chekout page, before sending theses details to fedex, i want to change the weight of the product, i Want to add additional value(this value is different for different products) multiplied with weight for each products in the cart, where i can add this, i am new in magento, could n't find where i can add this. – Naveenbos Jul 03 '15 at 09:49
  • If you need to add some extra information to your quote and order, you should add a new column in your sales_flat_order_quote and sales_flat_order tables using an alter table query. Then, in your event, populate those fields (assuming your column is called extra_fedex_weight, use the magic setter setExtraFedexWeight on your quote object) using your weight calculation logic. Step 3, in your fedex module, choose to send those extra information instead of the original weight. – beluga Jul 03 '15 at 10:09
  • I have no idea about where i can change this, please help me, i mend the files and functions – Naveenbos Jul 03 '15 at 12:11
  • In the front end view for users, we are showing the shipping rates in the cart page and checkout page, i am asking about this – Naveenbos Jul 03 '15 at 12:24
-1

Finally i find out that it is happening in the sales/quote/item.php file, there is a function called setProduct, here we need to add addititonal info while setting data.

public function setProduct($product)
    {

        $batchQty = Mage::getModel('catalog/product')->load($product->getId())->getBatchQty();
        $roleId     = Mage::getSingleton('customer/session')->getCustomerGroupId();
        $userrole   = Mage::getSingleton('customer/group')->load($roleId)->getData('customer_group_code');
        $userrole   = strtolower($userrole);
        if ($this->getQuote()) {
            $product->setStoreId($this->getQuote()->getStoreId());
            $product->setCustomerGroupId($this->getQuote()->getCustomerGroupId());
        }
        if($userrole=="retailer" && $batchQty>0 ){
            $this->setData('product', $product)
            ->setProductId($product->getId())
            ->setProductType($product->getTypeId())
            ->setSku($this->getProduct()->getSku())
            ->setName($product->getName())
            ->setWeight($this->getProduct()->getWeight()*$batchQty)
            ->setTaxClassId($product->getTaxClassId())
            ->setBaseCost($product->getCost())
            ->setIsRecurring($product->getIsRecurring());
        } else {
            $this->setData('product', $product)
            ->setProductId($product->getId())
            ->setProductType($product->getTypeId())
            ->setSku($this->getProduct()->getSku())
            ->setName($product->getName())
            ->setWeight($this->getProduct()->getWeight())
            ->setTaxClassId($product->getTaxClassId())
            ->setBaseCost($product->getCost())
            ->setIsRecurring($product->getIsRecurring());
        }

        if ($product->getStockItem()) {
            $this->setIsQtyDecimal($product->getStockItem()->getIsQtyDecimal());
        }

        Mage::dispatchEvent('sales_quote_item_set_product', array(
            'product' => $product,
            'quote_item' => $this
        ));
        return $this;
    }
Naveenbos
  • 2,532
  • 3
  • 34
  • 60