我想在"?"之后删除所有内容.在文件准备好的浏览器网址中.
这是我正在尝试的:
jQuery(document).ready(function($) {
var url = window.location.href;
url = url.split('?')[0];
});
Run Code Online (Sandbox Code Playgroud)
我可以这样做,看下面的工作:
jQuery(document).ready(function($) {
var url = window.location.href;
alert(url.split('?')[0]);
});
Run Code Online (Sandbox Code Playgroud) 我有一个包含选择选项的页面,我使用JQuery刷新页面,并在单击选项时向URL添加字符串.现在我需要一种方法来检查浏览器URL以查看它是否包含所述字符串.
看看我认为indexOf可行的其他线程,但在尝试时它不起作用.我怎么检查URL是否包含类似的内容?added-to-cart=555?完整的URL通常是这样的:http://my-site.com,并单击它看起来是这样的页面重载后一个选项后:http://my-site.com/?added-to-cart=555.我只需要检查URL是否包含该?added-to-cart=555位.
这是我有的:
jQuery("#landing-select option").click(function(){
$('#product-form').submit();
window.location.href += $(this).val()
});
jQuery(document).ready(function($) {
if(window.location.indexOf("?added-to-cart=555") >= 0)
{
alert("found it");
}
});
Run Code Online (Sandbox Code Playgroud) 我是laravel的新手,并且一直在与收银员合作开发我正在开发的网络应用程序.在我的应用程序中,用户创建他们的帐户和公司,并允许他们使用该应用程序.因为公司可以有很多用户,所以我需要收银员检查公司是否有订阅.
在使用Stripe 的收银员文档中,我已将其设置在预先不需要信用卡的位置,他们可以使用该系统14天,直到被提示输入信用卡.
到目前为止,我已经在我的公司表上成功创建了收银台列,并根据文档添加了子列表.
add_cashier_table_fields.php迁移文件:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddCashierTableFields extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::table('companies', function ($table) {
$table->string('stripe_id')->nullable();
$table->string('card_brand')->nullable();
$table->string('card_last_four')->nullable();
$table->timestamp('trial_ends_at')->nullable();
});
Schema::create('subscriptions', function ($table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->string('stripe_id');
$table->string('stripe_plan');
$table->integer('quantity');
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
Run Code Online (Sandbox Code Playgroud)
然后在我的公司模型中,我按照建议添加了Billable特征. Company.php - 模型
<?php …Run Code Online (Sandbox Code Playgroud) 我认为这很容易,但我在这里遗漏了一些东西。我正在使用 Stripe Connect 并尝试计算申请费(以美分为单位)。问题是我的申请费有时有小数,所以会抛出错误。我尝试过使用round(),它给了我和ceil()但我仍然在我的答案中得到一个小数和尾随零,所以它返回一个错误。
$payment = bcmul($request->amount, 100); //112.00 - Convert to cents for stripe becomes 11200
$applicationFee = $payment * 0.021; //235.2 but should be just 235
print_r($applicationFee); //Should be whole number, round and ceil still provide me with decimal number IE 235.0 instead of 235
Run Code Online (Sandbox Code Playgroud)
如何确保 applicationFee 始终是不带小数的整数并四舍五入到最接近的整数?
我花了太多时间在这上面,并在stackoverflow上浏览了各种问题/答案.
我正在使用dropzone.js为我们的HTML/PHP表单添加基本的拖放上传功能.拖放工作正常,但是当提交表单或上传文件时,$ _FILES返回空,我无法弄明白.
我查了教程和没有运气,也查了一些Q&A的距离计算器前张贴在这里,但没有任何帮助.
这是最简单形式的表单:
<form action="<? echo BASE_URL; ?>/process-uploads.php" method="POST" class="form-signin" role="form" enctype="multipart/form-data">
<div class="upload_container dropzone">Drag & drop file here or
<div class="fallback">
<input name="ad" type="file" />
</div>
</div><!--fileUpload btn btn-primary-->
<div class="dropzone-previews"></div>
<input class="btn btn-lg btn-primary btn-block btn-forward" style="background:#00a85a;" type="submit" name="submit" value="Next Step" />
</form>
Run Code Online (Sandbox Code Playgroud)
JS是:
<script type="text/javascript">
var myDropzone = new Dropzone(".dropzone", {
url: "<? echo BASE_URL; ?>/process-uploads.php/",
paramName: "ad",
addRemoveLinks: true,
//maxFiles: 1,
autoProcessQueue: false,
//uploadMultiple: …Run Code Online (Sandbox Code Playgroud) 我想我应该使用in_array()但由于某种原因它给我不准确的信息.我查看了array_search()和array_key_exists(),但看起来这只有在我的数组中有一个键和值时才有用.简而言之,我运行一个条件来获取当前的EST时间和日期,并确定它是"在几小时内"还是"在下班后".
所以现在是星期二晚上19点,这应该说是"非工作时间",但它回应"在工作时间",我错过了什么?
示例代码:
<?php
date_default_timezone_set('US/Eastern');
$current_time = date('A'); //AM or PM
$current_day = date('l'); // Sunday - Saturday
$current_hour = date('H'); // 08 / 24hr Time Format
$closed_days = array('Saturday','Sunday');
$closed_hours = array('17','18','19','20','21','22','23','00','01','02','03','04','05','06','07','08');
?>
<?php
echo $current_time . '<br />';
echo $current_day . '<br />';
echo $current_hour . '<br />';
//Operating Hours
if(!in_array($current_day, $closed_days) || !in_array($current_hour, $closed_hours)) {
echo 'During Hours';
} else {
echo 'After Hours';
} ?>
Run Code Online (Sandbox Code Playgroud)
回来了:
PM
Tuesday
19
During …Run Code Online (Sandbox Code Playgroud) 我需要找到一种方法来检查优惠券是否适用于Woocommerce结账,如果是的话我想做点什么.我试图寻找这个,但找不到解决方案.
这是我正在尝试的精简版:
add_action('woocommerce_before_cart_table', 'apply_product_on_coupon');
function apply_product_on_coupon( ) {
global $woocommerce;
$coupon_id = '12345';
if( $woocommerce->cart->applied_coupons === $coupon_id ) {
echo 'YAY it works';
}
}
Run Code Online (Sandbox Code Playgroud)
那么这不是检查购物车中是否存在优惠券的正确方法吗? if( $woocommerce->cart->applied_coupons === $coupon_id )
我有一个我正在创建的前端表单,允许用户使用预定义的属性和变体从前端向我的商店发布变量产品.
我找到了这个非常有用的问题:这里 显示了如何将产品类型设置为变量,并在产品数据的属性部分中分配我的预定义属性.
然而,当我在Wordpress/Woocommerce的后端并编辑产品时,我点击变体并且没有设置,我查看属性,我的"分辨率"属性设置为我的3项.
如何将它实际设置为我的表单的变体?我需要使用wp_insert_post吗?查看phpmyadmin,看起来产品变体分配给parent_id(产品ID),帖子类型是product_varition,依此类推.
$new_post = array(
'post_title' => esc_attr(strip_tags($_POST['postTitle'])),
'post_content' => esc_attr(strip_tags($_POST['postContent'])),
'post_status' => 'publish',
'post_type' => 'product',
'tags_input' => array($tags)
);
$skuu = rand();
$post_id = wp_insert_post($new_post);
update_post_meta($post_id, '_sku', $skuu );
//my array for setting the attributes
$avail_attributes = array(
'high-resolution',
'medium-resolution',
'low-resolution'
);
//Sets the attributes up to be used as variations but doesnt actually set them up as variations
wp_set_object_terms ($post_id, 'variable', 'product_type');
wp_set_object_terms( $post_id, $avail_attributes, 'pa_resolution' );
$thedata = array(
'pa_resolution'=> array(
'name'=>'pa_resolution', …Run Code Online (Sandbox Code Playgroud) 我正在使用WP网站,在我的模板中,我正在运行这样的循环:
<!-- START LOOP -->
<?php while ( have_posts() ) : the_post(); ?>
<div class="row" style="margin:15px 0;">
<div class="twelve columns">
<div class="four columns">
<a href="<?php the_permalink(); ?>">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'medium' );
} else {
echo 'No Preview Available';
}
?>
</a>
</div>
<div class="eight columns">
<h3><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></h3>
<p><?php the_excerpt() ?></p>
<p><a href="<?php echo esc_html( get_post_meta( get_the_ID(), 'portfolio_website', true ) ); ?>" target="_blank"><?php echo esc_html( get_post_meta( get_the_ID(), 'portfolio_website', true ) ); ?></a></p> …Run Code Online (Sandbox Code Playgroud) 我已经阅读了各种方法并使用了Clippy 工具,问题是浏览器支持尚不存在。使用 CSS 完成下图外观的最佳方法是什么?我正在尝试添加一个形状,bottom-border如下面的蓝色背景图像后面的图像所示。有没有一种方法可以做到这一点,最近的主要浏览器通过 CSS 支持?
我尝试过的(似乎在 Chrome 和其他人中不起作用):
.element {
-webkit-clip-path: polygon(50% 0%, 100% 0, 100% 86%, 75% 100%, 0 85%, 0 0);
clip-path: polygon(50% 0%, 100% 0, 100% 86%, 75% 100%, 0 85%, 0 0);
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用laravel-notifications-channel/onesignal,但我的 laravel 应用程序中的用户设置为接收通知时遇到了一些问题。在GitHub的页面文件并没有真正涵盖了用户如何认证他们自收到通知。
即使阅读OneSignal 文档以将用户发送到 OneSignal 也不适合我。
我如何设置当用户使用我们的网络应用程序时,他们会收到通知以接收通知,然后我可以使用laravel 通知向他们发送通知?
这是我的 AssignedToTask 通知文件:
<?php
namespace App\Notifications;
use App\Task;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\OneSignal\OneSignalChannel;
use NotificationChannels\OneSignal\OneSignalMessage;
use NotificationChannels\OneSignal\OneSignalWebButton;
class AssignedToTask extends Notification
{
use Queueable;
protected $task;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Task $task)
{
//
$this->task = $task;
}
/**
* Get the notification's delivery channels.
* …Run Code Online (Sandbox Code Playgroud) 因此,当您在元素上使用鼠标时,我一直在寻找复制Land Rover网站并添加动画鼠标效果的方法.例如,请查看此页面:http://www.landroverusa.com/index.html,看看在"滑块"区域中移动鼠标时会发生什么.它看起来像它的CSS来处理鼠标图像,但我如何复制像上面的网站一样标题鼠标指针图像的动画?
到目前为止,这是我所拥有的这个链接:
<style>
* {
cursor: none;
}
figure#mouse-pointer {
background-image: url('http://cdns2.freepik.com/image/th/318-70851.png');
background-size:44px 44px;
width: 44px;
height: 44px;
position: absolute;
margin-left: -8px;
display: block;
}
</style>
<figure id="mouse-pointer"></figure>
<script>
$(function (){
// Based on example found here: http://creative-punch.net/2014/01/custom-cursors-css-jquery/
$(window).mousemove(function(event) {
$('#mouse-pointer').css({
'top' : event.pageY + 'px',
'left' : event.pageX + 'px'
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
这是一个小提琴:https://jsfiddle.net/yqd5xzvc/1/
我有一个基于app.mydomain.com(服务器1)构建的应用程序,以及位于support.mydomain.com(服务器2)上的支持票务系统。 如何在laravel应用程序中的两个数据库之间建立连接?两者都使用Laravel Forge和Digital Ocean。
我在SO上阅读了这篇帖子,看起来不错,但出现“连接超时错误”。我认为这与Forge在连接数据库时需要SSH密钥文件(id_rsa.pub)有关吗? 来源在这里
我尝试将其添加到database.php:
//Server/Site 1
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'support',
'username' => 'user',
'password' => 'mysecretpassword',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
//Server/Site 2
'mysql2' => array(
'driver' => 'mysql',
'host' => '123.456.789.101',
'port' => '3306',
'database' => 'app',
'username' => 'forge',
'password' => 'mysecretpassword',
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
), …Run Code Online (Sandbox Code Playgroud) php ×7
javascript ×4
jquery ×4
laravel-5 ×3
wordpress ×3
css ×2
html ×2
laravel ×2
laravel-5.3 ×2
woocommerce ×2
arrays ×1
css-shapes ×1
css3 ×1
date ×1
dropzone.js ×1
forms ×1
loops ×1
mysql ×1
onesignal ×1
url ×1