我正在一个单独的模板页面,该页面使用wordpress post的自定义字段获取woocommece产品sku.我需要获得那个sku的产品ID来创建woocommece对象并做更多的事情,这是我的代码.
global $woocommerce;
//this return sku (custom field on a wordpress post)
$sku=get_field( "product_sku" );
if($sku!=''){
//need to create object, but using sku cannot create a object,
$product = new WC_Product($sku);
echo $product->get_price_html();
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在创建对象之前获取产品ID,然后我可以将产品ID传递给WC_Product类构造函数并创建object.thank you
我在网站上工作,在mac safari上的字体比其他浏览器大得多,
网站使用谷歌字体的'Open Sans'字体
ex-这是一个针对titile的css
h2.protitles{
color: #404040;
font-size: 22px;
text-transform: uppercase;
float: none;
}
Run Code Online (Sandbox Code Playgroud)
这显示如下面的chrome,firefox和IE如下,它很好
但是mac safari就是这样的
不知何故safari似乎为所有字体添加1px.
任何人都可以帮我解决这个问题,非常感谢
我的js弹出窗口有问题.
我打开一个弹出窗口并尝试访问其他页面页面中的元素,没有成功,我不想重新加载弹出源,我只想访问打开的弹出窗口的元素
前 -
第1页
var popup = window.open("test.html","mypopup","width=500,height=300");
Run Code Online (Sandbox Code Playgroud)
第二页我想访问mypopup windows元素而不重新加载弹出窗口
我只需要如何访问打开的弹出元素而不使用JS或JQuery中断其源代码
我window.open在文档ready事件中使用并调用它,但它被Firefox中的弹出窗口阻止程序阻止.然后我将其添加到该函数并从一个按钮调用此函数,然后触发按钮单击而不成功:
$(function(){
abcd();
});
function abcd(){
var popup = window.open("http://localhost/johndyer-mediaelement-7ed6c51/demo/index.php","mypopup","width=500,height=300");
}
Run Code Online (Sandbox Code Playgroud)
当页面加载时,是否有某种方法可以在浏览器上打开外部弹出窗口或新选项卡?
我创建了一个脚本,可以获取未读的电子邮件列表,因为这里的gmail是我的代码
<?php
//function to get unread emails taking username and password as parameters
function check_email($username, $password)
{
//url to connect to
$url = "https://mail.google.com/mail/feed/atom";
// sendRequest
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_ENCODING, "");
$curlData = curl_exec($curl);
curl_close($curl);
//returning retrieved feed
return $curlData;
}
//making page to behave like xml document to show feeds
header('Content-Type:text/xml; charset=UTF-8');
//calling function
$feed = …Run Code Online (Sandbox Code Playgroud) 我有一个数组,需要使用键值"odbyx"进行排序
这是数组var_dump
array(12) {
["id"]=> array(7) {
[0]=> string(1) "8"
[1]=> string(1) "7"
[2]=> string(1) "3"
[3]=> string(1) "6"
[4]=> string(1) "5"
[5]=> string(1) "2"
[6]=> string(1) "1"
}
["subject"]=> array(7) {
[0]=> string(14) "ticke tick sbj"
[1]=> string(13) "new tick test"
[2]=> string(15) "fdsfdsfdsfdsfds"
[3]=> string(12) "test subject"
[4]=> string(4) "test"
[5]=> string(4) "test"
[6]=> string(12) "test subject"
}
["msg"]=> array(7) {
[0]=> string(9) "test+tick"
[1]=> string(4) "test"
[2]=> string(9) "dfdsfdsfd"
[3]=> string(12) "test+tcikets"
[4]=> string(4) "test"
[5]=> …Run Code Online (Sandbox Code Playgroud) 我有日期和时间,如:
12-Oct-13 09:15 PM AEST
10-Oct-13 07:05 PM AEST
Run Code Online (Sandbox Code Playgroud)
我使用PHP的strtotime()函数像这样将它转换为datetime对象,如下所示:
echo $datetime=strtotime('12-Oct-13 09:15 PM AEST');
Run Code Online (Sandbox Code Playgroud)
但它得到了空洞的结果.我的想法是将上述日期时间转换为另一种格式,如:
12-10-2013 09:15 PM
10-10-2013 07:05 PM
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我正确转换为日期时间对象.然后我在我的代码中使用它.
我有一个PHP数组如下:
Array
(
[0] => 16
[1] => 17
[2] => 18
[3] => 23
[4] => 7
[5] => 6
[6] => 14
[7] => 22
)
Run Code Online (Sandbox Code Playgroud)
我需要两个将这个数组拆分为两个数组的23值,如下所示:
Array
(
[0] => 16
[1] => 17
[2] => 18
)
Array(
[0] => 23
[1] => 7
[2] => 6
[3] => 14
[4] => 22
)
Run Code Online (Sandbox Code Playgroud)
任何人都可以通过PHP知道如何做到这一点.
首先,我想说这不是一个重复的问题,我尝试了其他答案但没有成功。
我将 ACF 字段添加到 woocommerce 类别,我需要在 woocommerce 类别存档页面上显示该字段。
下面显示了我如何添加 ACF
http://www.awesomescreenshot.com/image/1859170/1fb3dc839dff36c92d4ee52f5167ca78
http://www.awesomescreenshot.com/image/1859175/1d1e43f70ae925ac5501f9e360f4a463
它显示在产品类别管理区域
http://www.awesomescreenshot.com/image/1859197/c5df7d20319c73d94896058daa6f3f2a
但是当我尝试在类别页面上显示时,它没有显示,
<?php
$queriedObject=get_queried_object();
echo get_field('categoryslider','product_cat_'.$queriedObject->term_id);
?>
Run Code Online (Sandbox Code Playgroud)
上面的代码是我从堆栈溢出中获得的,我还尝试了其他一些解决方案,但它不起作用,我正在使用所有插件的最新版本。
谁能帮助我吗?谢谢