Automatically add an extra shipping charge?

  • Posts: 38
  • Thank you received: 0
13 years 10 months ago #8526

Hello,

I have a question. Can I configure it to automatically add an additional shipping fee to the cart if the products in the cart add up to caetain weight or more?

Let me explain my needs. I will be selling a variety of products in my store. Some products will not weigh much, while other products will weigh a lot. If a customer wants to place an order for one or more products that add up to a weight of 150lbs or less, I do not want an extra shipping fee added. I just want the software to charge the shipping fee that UPS will charge. (I will need the UPS or Fedex shipping plugin for this when it is available).

Now, if the product(s) weigh more than 150lbs, I will ship the product through a freight service. In this case, I will need to package the products on a wooden crate to be shipped. I will need to charge a fee ($150 for example) for the crate and packaging. This fee will be in addition to the cost of the products and the cost of the freight shiping. (I will be working with a freight company that has their own shipping API, I will just need to have a developer integrate it into HikaShop)

So, is there a method that will allow the fee to be generated and automatically added to the shopping cart (as a unique charge)? I would need the fee to be its own unique item, because it will not be taxable, but the products and the shipping will be taxable. Also, I suppose that this fee could be an (invisible)item in my store that is only automatically added to the cart if the software calculates that the other products weigh over the set limit. Either way, can the software be configure to do this?

Thank you,
Chris

Please Log in or Create an account to join the conversation.

  • Posts: 83023
  • Thank you received: 13403
  • MODERATOR
13 years 10 months ago #8551

Hi,

There is no option for that in HikaShop but you can always add it. As you said you can add automatically a product to the cart if the weight of the cart is over a certain weight. You could edit the file cart of the view checkout and add some code to check on the weight and that invisible product:

$weight = 0;
$invisible_present = false;
foreach($this->rows as $k => $product){
         if($product->product_id==XX) $invisible_present = true;

	 if(!empty($product->cart_product_quantity) && bccomp($product->product_weight,0,5)){
		 $weight+=$product->product_weight*$product->cart_product_quantity;
	 }
}

if($weight>150){
 if(!$invisible_present){
  $app =& JFactory::getApplication();
  $app->redirect(hikashop::completeLink('product&task=updatecart&product_id=XX&quantity=1&add=0&return='.urlencode(base64_encode(hikashop::currentUrl())),false));
 }
}else{
 if($invisible_present){
  $app =& JFactory::getApplication();
  $app->redirect(hikashop::completeLink('product&task=updatecart&product_id=XX&quantity=0&add=0&return='.urlencode(base64_encode(hikashop::currentUrl())),false));
 }
}

Last edit: 13 years 9 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 38
  • Thank you received: 0
13 years 10 months ago #8620

Hi Nicolas,

I could not get the code to work. I have to admit, I am not good with code at all, but I was able to get the code you posted in my other topic to work.

I copied the your code and pasted it near the bottom in the file you noted. I don't know if there is a special place that it should pasted, or if there are restrictions on where it should be placed

On my checkout page, below the Final Total, it just displays the code I had posted.

Is there a certain way I need to paste the code?

Thank you,
Chris

P.S.

Also, I want to add the following information regarding my initial post and what I want to accomplish. With regard to you agreeing that adding an "invisible" product for the extra shipping fee to the cart if the weight is over a certain, I'm glad you think I can accomplish this with your suggested code.

When I referred to the item as "invisible", I was trying to suggest is that I have a product in my store named "Additional Crate Fee". (I guess I could place this product in the root of the store, or maybe a catagory called shipping, so as long its not shown in the menu or the content of the store) This product would not be visible to anyone shopping in the store, so it would be "invisible" to my customers. Then, if the total weight of the cart was greater than 150lbs, the software would activate the Additional Crate Fee and automatically add it as an individual product that would now be shown as an item in the cart.

I do believe that you did understand my initial explination, but I just wanted to try to make sure I am as clear as I can.

Thank you.

Last edit: 13 years 10 months ago by QuantumView.

Please Log in or Create an account to join the conversation.

  • Posts: 83023
  • Thank you received: 13403
  • MODERATOR
13 years 10 months ago #8622

You should put it just after the first <?php in that file. Now I don't know if that code works as it's not tested. I just wrote it to you from memory as a pointer...
Also note that the several XX in the code should obviously be replaced with the id of your invisible product that you must create beforehand.

Please Log in or Create an account to join the conversation.

  • Posts: 38
  • Thank you received: 0
13 years 10 months ago #8625

Ok, I will try pasting the code where you indicate. And I see that you use the term 'invisible'l in your code. I want to add the following information regarding my initial post and what I want to accomplish. With regard to you agreeing that adding an "invisible" product for the extra shipping fee to the cart if the weight is over a certain, I'm glad you think I can accomplish this with your suggested code. When I referred to the item as "invisible", I was trying to suggest is that I have a product in my store named "Additional Crate Fee". (I guess I could place this product in the root of the store, or maybe a catagory called shipping, so as long its not shown in the menu or the content of the store) This product would not be visible to anyone shopping in the store, so it would be "invisible" to my customers. Then, if the total weight of the cart was greater than 150lbs, the software would activate the Additional Crate Fee and automatically add it as an individual product that would now be shown as an item in the cart. I do believe that you did understand my initial explination, but I just wanted to try to make sure I am as clear as I can. Thank you.

Please Log in or Create an account to join the conversation.

  • Posts: 83023
  • Thank you received: 13403
  • MODERATOR
13 years 10 months ago #8637

Yes. You can just set your product in an unpublished category and that will avoid it showing up in your store.

Please Log in or Create an account to join the conversation.

  • Posts: 38
  • Thank you received: 0
13 years 9 months ago #9210

Hi Nicolas,

OK, I have been trying to get this to work for a few days. I created a category called "Shipping Fees" in the root of the store, and made sure the category was not published. Then I created a product called "Additional Crate Fee", made sure it was published and assigned it to the "Shipping Fees" category. I placed your code in the location you noted, and made sure that the XX's were changed to the ID number of the "Additional Shipping Fee" product.

I have a few sample products in the store now, each with different weights. When I add products from the store that do not add up to 150lbs, and click the "Proceed to checkout" button in the mini-cart, it takes me to the checkout page without problems.

If I add products to the cart that add up to over 150lbs, and click on the "Proceed to checkout" button, the page just keeps going through a continuous and quick regenerating cycle between two pages. It appears that one page is blank, while the other page shows what looks like a partial, unformatted view of the checkout page. It displays simple boxes for billing address, shipping address, payment information, and coupon code. When I stop the page from continuously regenerating, it is blank, but the URL shows one of the two following ......com/online-store/product/updatecart/product_id-4/quantity-1/add-1/return-aHR0cDovL3d3dy5kaXlraXRjaGVuYW5kYmF0aC5jb20vb25saW5lLXN0b3JlL2NoZWNrb3V0 -or- .....com/component/hikashop/checkout

When I press the back button in the web browser, it returns to the website home page. At the beginning of the page it shows and error of "No shipping method found", except that it is displayed over 20 times. Maybe from the continuous regenerating? I want to note that I do not have my shipping methods defined yet. Additionally, in the mini-cart, it shows the "Additional Crate Fee" product added in the cart. I changed the "Maximum quantity per order" option for the "Additional Crate Fee" product, otherwise it would show a large quantity in the mini-cart after pressing the back button, and I only want to have it added one time. So it appears that maybe some of the code is working because the "Additional Crate Fee" has been added, but it is obviously not working the way it should. All this is in Google Chrome.

Do you have any ideas why this is not working, and what I can do next to get it working. I feel that we are close, and I can get this working with just a little fixing.

Thank You,
Chris

Please Log in or Create an account to join the conversation.

  • Posts: 83023
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #9221

I changed a bit the code as there was a bug in it. It should work better now.

As I said, the code was written without testing it, so I would have been surprised that it would have worked on the first try.

Please Log in or Create an account to join the conversation.

  • Posts: 38
  • Thank you received: 0
13 years 9 months ago #9642

Hi Nicolas,

I want to give you an update on the development. I replaced the old code with your new updated code. It works much better. It now automatically adds the "Additional Crate Fee" when the weight of the cart is more than 150lbs. But I have encountered an issue. When the weight of the cart is more than 150lbs and the "Additional Crate Fee" is included in it, and then I try to delete items in the cart, I get the same problem as before with the continuously regeneraging pages.

So it appears that your code work correctly adding the "Additional Crate Fee", but there appears to be a problem when it trys to remove the "Additional Crate Fee". Do you have any suggestions to fix this function?

Thank you again!!!

Please Log in or Create an account to join the conversation.

  • Posts: 83023
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #9644

Ok. I updated again the code. Could you try with that new version ?

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
11 years 3 months ago #124747

Hi Nicolas, I have a similar task. Now I have two shipping methods (by post and self pick up). And I want to add that invisible product (price for packaging) to the cart if the postal method is chosen. I know that I can add both the packaging and the shipping prices together in the manual shipping plugin, but I want to devide them. Can you point me please at some code that can provide this.
Thank you for your answer.

Last edit: 11 years 3 months ago by denoo.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 2 months ago #124851

Hi,

I think that you will have to create a plugin which will add or remove a product depending on the selected shipping method.
I require good php level.
www.hikashop.com/support/documentation/6...r-documentation.html

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
11 years 2 months ago #124856

Hi Xavier,
thank you. I'll try it. Unfortunately my php level isn't good.

Please Log in or Create an account to join the conversation.

Time to create page: 0.102 seconds
Powered by Kunena Forum