我有以下代码在购物车和结帐页面的总部分添加后缀文本:
add_filter( 'woocommerce_cart_total', 'custom_total_message' );
function custom_total_message( $price ) {
$msg = 'Prices for grocery items may vary at store. Final bill will be based on store receipt.<br />';
return $price . $msg;
}
Run Code Online (Sandbox Code Playgroud)
但是,我只希望后缀文本仅显示在结帐而不是购物车页面中。
我该如何实现?
我有一个测试器类,我正在尝试使用全局帮助器方法base_path(),但我得到以下错误:
Error: Call to undefined method Illuminate\Container\Container::basePath()
/myproject/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:182
/myproject/tests/Feature/DataCsvSeedTest.php:31
/myproject/vendor/phpunit/phpunit/src/TextUI/Command.php:195
/myproject/vendor/phpunit/phpunit/src/TextUI/Command.php:148
Run Code Online (Sandbox Code Playgroud)
看起来像Laravel中的helper.php调用了basePath(),但找不到它.我是否缺少全局帮助函数的命名空间或其他设置?使用Laravel 5.5.
<?php
namespace Tests\Feature;
use Tests\TestCase;
class DataCsvSeedTest extends TestCase
{
public function setUp()
{
$baseDir = base_path();
print "basedir = ". $baseDir;
}
}
Run Code Online (Sandbox Code Playgroud)