php


Custom Woocommerce Shipping Calculation


Have setup woocommerce to add surcharges to shipping but I only the surcharges added to the shipping method called "Toll IPEC". I added the foreach loop so would go through the array and if matched add the charges but its not entering the loop and adding the charges. Can someone please tell me what I'm doing wrong here?
add_filter( 'woocommerce_package_rates', 'add_shipping_percentage_surcharge', 10, 2 );
function add_shipping_percentage_surcharge( $rates, $package ) {
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
foreach( $chosen_methods as $key => $value1) {
if ($value1 =='Toll IPEC')
{
foreach( $rates as $key => $value ) {
if( $value->method_id == 'betrs_shipping' ) {
$rates[ $key ]->cost += $rates[ $key ]->cost * 0.12;
$rates[ $key ]->cost += $rates[ $key ]->cost * 0.10;
$rates[ $key ]->cost += $rates[ $key ]->cost * 0.30;
}
}
}
}
return $rates;
}

Related Links

pagination not working for taxonomy
PHP -> simplexml_load_file skip to next when error
How to correct and change a static method to a non-static method for Joomla module
How to individual print every word of a sentence in PHP? [closed]
JetBrains PhpStorm Not Resolving Server Variable?
couldn't fetch session value to another page
Edit YAML array with php Symfony2.8
preg_replace and hidden chars or hidden encoding
BelongsToMany with BelongsToMany relation [closed]
What is equivalent of strtotime in SQL?
Expecting statement after if
Extract array from inside array
How to group from MySQLi using PHP
How to file_get_contents from HTTPS with basic authentication?
WordPress custom taxonomy query
Server Concurrency with High CPU Load

Categories

HOME
xpath
apple-push-notifications
postgresql-9.4
initialization
apk
autocomplete
share
facebook-android-sdk
haxe
tweepy
yahoo
business-intelligence
createjs
asp.net-core-1.0
sonicwall
asciimath
checkout
error-logging
coreldraw
fido-u2f
altium-designer
gollum-wiki
websphere-portal
ipa
microprocessors
matlab-app-designer
quickcheck
cups
hidden-markov-models
text-decorations
sbjson
oauth2-playground
fluid-mac-app-engine
windows-media-player
roracle
image-registration
supertest
comm
htmlspecialchars
google-news
gnome-terminal
.when
cognos-tm1
streamwriter
e
system.web.optimization
jsf-2.3
raw-sockets
android-async-http
django-redis
persistent-object-store
teensy
juniper-network-connect
variable-length-array
apache-commons-digester
highest
asp.net-web-api-helppages
ngcordova
vdm-sl
swagger-maven-plugin
relational-model
physicsjs
shoes
nssortdescriptor
rebar
smacss
adwords-apiv201402
squeezebox
windows-messages
jomsocial
armv6
spring-security-acl
application-server
rautomation
iirf
jbox2d
linkbutton
cgrectmake
instance-variables
servercontrol
canonicalization
tablet-pc
asp.net-mvc-views
eaccelerator
ios-4.2
resharper-5.1
3-tier
data-retrieval
regioninfo
chronic

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App