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

Connecting through PHP to a MySQL user with less privileges
AngularJS without framework
Dynamic change of content in tabs
How to get object id from post?
How To Convert Anonymous Function with USE to PHP 5.2 Compatible One?
Regular Expression for 3 Alphabets followed by one space followed by one digit
Property CWebApplication.Cookies is not defined
Autocomplete doesn't work anymore
Find file and rename it automaticly with php coding [closed]
Saving Mutiple image path to the Database
fwrite() in php not working
php: img src minus two folders
How to sum different columns from one table and get the sum result in another table using PHP or MySQL?
PHP: Removing excess linebreaks from a string
why can't windows based php exec() run svn command with url defined?
MySql PHP Combine Select Queries 1

Categories

HOME
memory
list
ontouchlistener
xcode8.1
theano
android-emulator
yql
liferay-7
azure-data-lake
static-analysis
timber
jpa-criteria
parsley.js
clish
android-externalstorage
multi-step
bundler
synthesis
hidden
spam
sharedpreferences
kamailio
qa
fluent-migrator
substring
react-dnd
raima
msdeploy
history.js
ibm-connections
credit-card
commonsware-cwac
serversocket
winrm
adminer
apptentive
autoencoder
dreamfactory
textmate2
bluemixtools
sbjson
system-on-chip
opal-framework
fiware-wirecloud
oracle-bmcs
autorelease
.net-micro-framework
image-registration
nothing
sequence-diagram
zend-server
oracle-fusion-apps
ternary-operator
ipywidgets
svnserve
nvda
between
piping
deferred-rendering
noclassdeffounderror
rails-engines
vimperator
as3-api
godeps
ambiguity
alwayson
pass-by-value
nhibernate-criteria
directorysearcher
dos2unix
microsoft-expression-web
ildasm
inputbox
osascript
webmethod
cpu-time
sunstudio
blobstorage
flv
semicolon
towers-of-hanoi
live-wallpaper
affinetransform
glassfish-esb
uipasteboard
kernel32
fragment-identifier
qcar-sdk
mongrel2
gaelyk
cassini
icicles
mysqli-multi-query
processors
server-load

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