我想在woocommerce中获得特定的自定义属性.我已经在这个网站上阅读了大量的线程,提供了大约3-5种方法.在尝试了所有之后,对我有用的唯一方法是遍历所有属性 - 所有其他属性都不起作用.我有一个名为'pdfs'的自定义属性
下面的尝试没有工作: (链接)
$global product;
$myPdf = array_shift( wc_get_product_terms( $product->id, 'pdfs', array( 'fields' => 'names' ) ) );
$myPdf = $product->get_attribute( 'pdfs' );
$myPdf = get_post_meta($product->id, 'pdfs', true);
Run Code Online (Sandbox Code Playgroud)
这是做的工作只有一个: (链接)
$attributes = $product->get_attributes();
foreach ( $attributes as $attribute ) {
if (attribute_label( $attribute[ 'name' ] ) == "pdfs" ) {
echo array_shift( wc_get_product_terms( $product->id, $attribute[ 'name' ] ) );
}
}
Run Code Online (Sandbox Code Playgroud)
我宁愿能够使用第一个选项之一任何帮助将不胜感激.
谢谢
我有Worksheet_SelectionChange功能.在第一行中,我想条件是如果选择了多于1个单元格,则退出.我写:
If Target.Cells.Count > 1 Then Exit Sub
Run Code Online (Sandbox Code Playgroud)
但是,当我选择整个工作表时,我收到一条错误消息:"运行时错误6 - 溢出"
好像Target.Count无法处理如此庞大的数字?
我该怎么做才能解决这个问题?
我正在循环访问目录中的文件并使用 StreamWriter 将文件名写入输出文件。文件大小不能超过 60K 检查此问题的最佳方法是什么?现在,我在每个循环中创建一个新的 FileInfo 变量(如下面的代码所示)并检查其 Length 属性,如以下代码所示:
foreach (var file in directories)
{
if (file.FullName.Contains("\\BAK\\")) continue;
myStream.WriteLine(file.FullName);
counter += 1;
FileInfo myPaths = new FileInfo(outFile);
if (myPaths.Length >= 60000)
{
//Do Procedure
}
}
Run Code Online (Sandbox Code Playgroud)
我在想,也许在写入之前计算每个字符串的长度会更快更简单。IE,
fileSz += file.FullName.Length
if (fileSz >= 60000) // do procedure
Run Code Online (Sandbox Code Playgroud)
或者也许还有另一种选择?