Update Shipment Prices

  • Posts: 108
  • Thank you received: 4
  • Hikashop Business Hikashop Style
11 years 5 months ago #74276

Hello there

I started to explore the Manual Shippment Plugin of HikaShop to learn how the things work, so that I can write my own module, fitting the need of my business / Swiss Post System.

I have the need, that I can send things with a special additional server called "Eingeschrieben". It means, that the Swiss Post guarantes the delivery or send the letter/packet back to the sender.

Therefore I added an additional field on the product (since this is something that the kind of the product demands in my case). I added the field product_delivery_options to product table and the possible value can be: "registered" or "registered-personally".

I have added the following code to manual.php of the manual shipping plugin to the function "onShippingDisplay(...)". It's just to try out a little bit the mechanics of the plugins:
(Ignore the maximum_height stuff for the moment... this is another requirement):

$overall_maximum_height = 0;
    $overall_has_signature = false;
    $overall_has_signature_personal = false;
    
    foreach($order->products as $k => $row) {
      if($row->product_height > $overall_maximum_height)
      {
        $overall_maximum_height = $row->product_height;
      }
      
      if(strcasecmp($row->product_delivery_options, "registered") == 0){
        $overall_has_signature = true;
      }
      
      if(strcasecmp($row->product_delivery_options, "registered-personally") == 0){
        $overall_has_signature_personal = true;
      }
    }
    
    foreach($rates as $k => $rate){
      if($overall_has_signature) {
        $rates[$k]->shipping_params->shipping_price_orig = $rates[$k]->shipping_params->shipping_price;
        
        $tempShippingPrice  = (float)$rates[$k]->shipping_params->shipping_price;
        $rates[$k]->shipping_params->shipping_price = $tempShippingPrice + 5.0;
      }
      if($overall_has_signature_personal) {
        if($rates[$k]->shipping_params->shipping_price_orig != 0) {
          $rates[$k]->shipping_params->shipping_price_orig = $rates[$k]->shipping_params->shipping_price;
        }
        $tempShippingPrice  = (float)$rates[$k]->shipping_params->shipping_price;
        $rates[$k]->shipping_params->shipping_price = $tempShippingPrice + 1.0;
      }
    }

My problem is, that the rates are not updated. I can't see the updated amount in the Checkout-Process and also in the NetBeans IDE, there seems to be no change for shipping_price. What am I doing wrong? Why can't I change the shipping price? Maybe it's a PHP-Related thing and has nothing todo with HikaShop, but I stuck and therefore I'm asking if there is a trick or something I miss.

Thanks for your help and best regards
Mike

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 5 months ago #74385

Hi,

As far as I can see that code looks right.
However, note that once selected, a shipping method information is stored in the user session. So unless you change the product quantity or the address or logout/login, you won't see the new prices.

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

  • Posts: 108
  • Thank you received: 4
  • Hikashop Business Hikashop Style
11 years 5 months ago #74441

nicolas wrote: However, note that once selected, a shipping method information is stored in the user session. So unless you change the product quantity or the address or logout/login, you won't see the new prices.


Hmm, okay... I'm not sure what this means. I have deactivated an automatic selection of the shipping method. I can see that the function "onShippingDisplay()" will be triggered 2 times (in case when the customer is not logged in), or it will be triggered 1 time when the customer is logged in.

Do I have to delete the browser cache or something between my debug sessions maybe?

I'll keep trying...

Another thing is: What do I have todo to store the settings? I now created a new module. In fact, I copied the existing "manual" plugin and changed all the XML "Manual" Names, including the filenames and the classname (plgHikashopshippingManual -> plgHikashopshippingSwissPostManual).

I changed 2 things in the "swisspostmanual_configuration.php" where I have no idea if it's correct:

From:
<a href="<?php echo hikashop_completeLink('plugins&plugin_type=shipping&task=edit&name='.$this->data['manual'].'&subtask=shipping_edit&shipping_id='.$rate->shipping_id);?>"><?php echo $rate->shipping_name;?></a>

<span class="spanloading"><?php echo $this->data['toggleClass']->delete($id,"manual-".$rate->shipping_id,'shipping',true); ?></span>

<input type="hidden" name="name" value="manual" />

To:
<a href="<?php echo hikashop_completeLink('plugins&plugin_type=shipping&task=edit&name='.$this->data['swisspostmanual'].'&subtask=shipping_edit&shipping_id='.$rate->shipping_id);?>"><?php echo $rate->shipping_name;?></a>

<span class="spanloading"><?php echo $this->data['toggleClass']->delete($id,"swisspostmanual-".$rate->shipping_id,'shipping',true); ?></span>

<input type="hidden" name="name" value="swisspostmanual" />

I can open/edit a configuration (in fact click "New"), but when I store it, the table with all configurations is empty. How does the storing mechanisms work or what do I have todo to store the settings? I couldn't figure that out till now :unsure:

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
11 years 5 months ago #74894

Hi,

Delete the browser's cache no, but logout/login in order to reset the user session, yes.

You need to change also all the "manual" in the manual.php

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

Time to create page: 0.049 seconds
Powered by Kunena Forum